mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-05 03:21:42 +00:00
Implement CvSink.
* Make CvSink constructor explicit. * Add SetDescription function.
This commit is contained in:
@@ -189,6 +189,8 @@ void CS_ReleaseSink(CS_Sink sink, CS_Status* status);
|
||||
//
|
||||
// OpenCV Sink Functions
|
||||
//
|
||||
void CS_SetSinkDescription(CS_Sink sink, const char* description,
|
||||
CS_Status* status);
|
||||
uint64_t CS_GrabSinkFrame(CS_Sink sink, struct CvMat* image, CS_Status* status);
|
||||
char* CS_GetSinkError(CS_Sink sink, CS_Status* status);
|
||||
void CS_SetSinkEnabled(CS_Sink sink, CS_Bool enabled, CS_Status* status);
|
||||
|
||||
@@ -182,6 +182,8 @@ void ReleaseSink(CS_Sink sink, CS_Status* status);
|
||||
//
|
||||
// OpenCV Sink Functions
|
||||
//
|
||||
void SetSinkDescription(CS_Sink sink, llvm::StringRef description,
|
||||
CS_Status* status);
|
||||
uint64_t GrabSinkFrame(CS_Sink sink, cv::Mat& image, CS_Status* status);
|
||||
std::string GetSinkError(CS_Sink sink, CS_Status* status);
|
||||
llvm::StringRef GetSinkError(CS_Sink sink, llvm::SmallVectorImpl<char>& buf,
|
||||
|
||||
@@ -340,7 +340,7 @@ class CvSink : public VideoSink {
|
||||
/// WaitForFrame() must be called on the created sink to get each new
|
||||
/// image.
|
||||
/// @param name Source name (arbitrary unique identifier)
|
||||
CvSink(llvm::StringRef name);
|
||||
explicit CvSink(llvm::StringRef name);
|
||||
|
||||
/// Create a sink for accepting OpenCV images in a separate thread.
|
||||
/// A thread will be created that calls WaitForFrame() and calls the
|
||||
@@ -352,6 +352,10 @@ class CvSink : public VideoSink {
|
||||
/// unusual circumstances) WaitForImage().
|
||||
CvSink(llvm::StringRef name, std::function<void(uint64_t time)> processFrame);
|
||||
|
||||
/// Set sink description.
|
||||
/// @param description Description
|
||||
void SetDescription(llvm::StringRef description);
|
||||
|
||||
/// Wait for the next frame and get the image.
|
||||
/// @return Frame time, or 0 on error (call GetError() to obtain the error
|
||||
/// message);
|
||||
|
||||
@@ -290,6 +290,11 @@ inline CvSink::CvSink(llvm::StringRef name,
|
||||
m_handle = CreateCvSinkCallback(name, processFrame, &m_status);
|
||||
}
|
||||
|
||||
inline void CvSink::SetDescription(llvm::StringRef description) {
|
||||
m_status = 0;
|
||||
SetSinkDescription(m_handle, description, &m_status);
|
||||
}
|
||||
|
||||
inline uint64_t CvSink::GrabFrame(cv::Mat& image) const {
|
||||
m_status = 0;
|
||||
return GrabSinkFrame(m_handle, image, &m_status);
|
||||
|
||||
Reference in New Issue
Block a user