-
Notifications
You must be signed in to change notification settings - Fork 48
cisstStereoVision tutorial 4
Anton Deguet edited this page May 5, 2014
·
2 revisions
-
CMakeLists.txt
: CMake script for creating compiler dependent projects -
CMyFilter1.h
: Custom filter 1 class declaration -
CMyFilter1.cpp
: Custom filter 1 class definition -
main.cpp
: Application entry point (main()
function)
All files can be found under cisstStereoVision/examples/tutorial3
.
PROJECT(svlTutorial3)
FIND_PACKAGE(cisst REQUIRED)
IF(cisst_FOUND)
INCLUDE(${CISST_USE_FILE})
ADD_EXECUTABLE(${PROJECT_NAME}
CMyFilter1.h
CMyFilter1.cpp
main.cpp
)
CISST_TARGET_LINK_LIBRARIES(${PROJECT_NAME} cisstCommon cisstVector cisstOSAbstraction cisstMultiTask cisstStereoVision)
ENDIF(cisst_FOUND)
#include <cisstStereoVision/svlFilterBase.h>
class CMyFilter1 : public svlFilterBase
{
public:
CMyFilter1();
protected:
int Initialize(svlSample* syncInput, svlSample* &syncOutput);
int Process(svlProcInfo* procInfo, svlSample* syncInput, svlSample* &syncOutput);
};
#include "CMyFilter1.h"
CMyFilter1::CMyFilter1() :
svlFilterBase() // Call baseclass' constructor
{ //
AddInput("input", true); // Create synchronous input connector
AddInputType("input", svlTypeImageRGB); // Set sample type for input connector
//
AddOutput("output", true); // Create synchronous ouput connector
SetAutomaticOutputType(true); // Set output sample type the same as input sample type
}
int CMyFilter1::Initialize(svlSample* syncInput, svlSample* &syncOutput)
{
syncOutput = syncInput; // Pass the input sample forward to the output
return SVL_OK; //
}
int CMyFilter1::Process(svlProcInfo* procInfo, svlSample* syncInput, svlSample* &syncOutput)
{
_OnSingleThread(procInfo) // Execute the following block on one thread only
{ //
svlSampleImageRGB* image = (svlSampleImageRGB*)syncInput; // Cast input sample to RGB image type
svlRGB* pixel = (svlRGB*)image->GetUCharPointer(); // Get RGB pixel buffer for in-place modifications
unsigned int pixelcount = image->GetWidth() * image->GetHeight(); // Get number of pixels in image
//
for (unsigned int i = 0; i < pixelcount; i ++, pixel ++) { // for each pixel ...
pixel->r = 255 - pixel->r; // process 'red' channel
pixel->g = 255 - pixel->g; // process 'green' channel
pixel->b = 255 - pixel->b; // process 'blue' channel
} //
} //
//
syncOutput = syncInput; // Pass the modified sample forward to the output
//
return SVL_OK; //
}
#include <cisstStereoVision.h>
#include "CMyFilter1.h"
int main()
{
svlInitialize(); // Discover supported devices and codecs
//
svlStreamManager stream; // Instantiate SVL Stream
svlFilterSourceVideoCapture source(1); // Instantiate video capture filter
CMyFilter1 filter1; // Instantiate user-implemented filter #1
svlFilterImageWindow window; // Instantiate image window filter
//
source.SetDevice(0); // Select first available capture device
//
stream.SetSourceFilter(&source); // Assign source filter to stream
source.GetOutput()->Connect(filter1.GetInput()); // Connect source filter to filter #1
filter1.GetOutput()->Connect(window.GetInput()); // Connect filter #1 to window filter
//
stream.Play(); // Initialize and Play video stream
//
char ch; //
std::cin >> ch; // (Wait for key-press)
//
stream.Release(); // Release stream
//
return 0; //
}
- Home
- Libraries & components
- Download
- Compile (FAQ)
- Reference manual
- cisstCommon
- cisstVector
- cisstNumerical
- cisstOSAbstraction
- TBD
- cisstMultiTask
- cisstRobot
- cisstStereoVision
- Developers