-
Notifications
You must be signed in to change notification settings - Fork 48
cisstStereoVision tutorial 2
- Filters
- Streams
- Samples
- Inputs and Outputs
- Connections
Code under git repository: cisstStereoVision/tutorial1/CMakeLists.txt
# Assign name to the project
PROJECT(svlTutorial1)
# Some version checking for CMake
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
# Setup dependency to CISST libraries
FIND_PACKAGE(cisst REQUIRED)
IF(cisst_FOUND)
# Inherit project settings from CISST (include directories, library directories, compiler options, etc.)
INCLUDE(${CISST_USE_FILE})
# Create executable file 'svlTutorial1' from source file 'main.cpp'
ADD_EXECUTABLE(${PROJECT_NAME} main.cpp)
# Specify which CISST libraries need to be linked against
CISST_TARGET_LINK_LIBRARIES(${PROJECT_NAME} cisstCommon cisstVector cisstOSAbstraction cisstMultiTask cisstStereoVision)
ENDIF(cisst_FOUND)
Code under git repository: cisstStereoVision/examples/tutorial1/main.cpp
#include <cisstStereoVision.h>
int main()
{
svlInitialize(); // 1. Discover supported devices and codecs
svlStreamManager stream; // 2. Instantiate SVL Stream
svlFilterSourceVideoCapture source(1); // 3. Instantiate video capture filter
svlFilterImageWindow window; // 4. Instantiate image window filter
source.SetDevice(0); // 5. Select first available capture device
stream.SetSourceFilter(&source); // 6. Assign source filter to stream
source.GetOutput()->Connect(window.GetInput()); // 7. Connect source filter to window filter
stream.Play(); // 8. Initialize and Play video stream
char ch;
std::cin >> ch; // (Wait for key-press)
stream.Release(); // 9. Stop and Release stream
return 0;
}
cisstStereoVision has a built in support for stereoscopic capture and processing. Video capture filters may take an unsigned int
argument in the constructor that specifies the number of parallel video channels to be handled together in one stream.
Please note: The architecture supports any number of video channels within a stream, however in the current implementation capture filters support only 1 or 2 video channels.
// stereo stream
svlFilterSourceVideoCapture source_s(2);
source_s.SetDevice(0, 0, SVL_LEFT); // device=0, input=0, channel=LEFT
source_s.SetDevice(1, 0, SVL_RIGHT); // device=1, input=0, channel=RIGHT
// mono stream
svlFilterSourceVideoCapture source_m(1);
source_m.SetDevice(2); // device=2, input=0, channel=LEFT
// First the source filter needs to be assigned to the stream
stream.SetSourceFilter(&source);
// Then filters need to be connected by establishing connections between their input and output ports
source.GetOutput()->Connect(filter1.GetInput());
filter1.GetOutput()->Connect(filter2.GetInput());
The methods GetInput
and GetOutput
take one optional std::string &
argument. If the argument is omitted then the methods return a pointer to the synchronous input or synchronous output port of the filter.
If the argument is specified, then the methods look up the input or output that has the same name as the specified string argument. The specified name may correspond to either synchronous or asynchronous port.
// Establishing 'synchronous' connection
filter1.GetOutput()->Connect(filter2.GetInput());
// Establishing 'asynchronous' connections
filter1.GetOutput("output2")->Connect(filter2.GetInput());
filter2.GetOutput()->Connect(filter3.GetInput("input2"));
filter3.GetOutput("output2")->Connect(filter4.GetInput("input2"));
Code under git repository: cisstStereoVision/examples/tutorial1/main.cpp
#include <cisstStereoVision.h>
int main()
{
svlInitialize(); // 1. Discover supported devices and codecs
svlStreamManager stream; // 2. Instantiate SVL Stream
svlFilterSourceVideoCapture source(1); // 3. Instantiate video capture filter
svlFilterSplitter splitter; // 4. Instantiate stream splitter filter
svlFilterImageResizer resizer; // 5. Instantiate image resizer filter
svlFilterImageUnsharpMask sharpen; // 6. Instantiate unsharp masking filter
svlFilterImageWindow window; // 7. Instantiate first image window filter
svlFilterImageWindow window2; // 8. Instantiate second image window filter
source.SetDevice(0); // 9. Select first available capture device
splitter.AddOutput("async_out"); // 10. Add 2nd output to stream splitter filter
resizer.SetOutputSize(400, 300); // 11. Setup image resizer filter
sharpen.SetAmount(200); // 12. Setup unsharp masking filter
sharpen.SetRadius(5);
sharpen.SetThreshold(2);
stream.SetSourceFilter(&source); // 15. Assign source filter to stream
source.GetOutput()->Connect(splitter.GetInput()); // 16. Connect source filter to splitter filter
splitter.GetOutput()->Connect(resizer.GetInput()); // 17. Connect splitter output #1 to resizer filter
resizer.GetOutput()->Connect(window.GetInput()); // 18. Connect resizer filter to 1st window filter
splitter.GetOutput("async_out")->Connect(sharpen.GetInput()); // 19. Connect splitter output #2 to unsharp masking filter
sharpen.GetOutput()->Connect(window2.GetInput()); // 20. Connect unsharp masking filter to 2nd window filter
stream.Play(); // 21. Initialize and Play video stream
char ch;
std::cin >> ch; // (Wait for key-press)
stream.Release(); // 22. Stop and Release stream
}
// After instantiation of the splitter filter
// it only has one default synchronous output
svlFilterSplitter splitter;
// By calling the AddOutput() method, you can
// create any number of synchronous outputs on
// the splitter. Each output on a single splitter
// needs to have a unique name.
splitter.AddOutput("out2");
splitter.AddOutput("out3");
filter1.GetOutput()->Connect(splitter.GetInput());
// Connect the synchronous output of the splitter
// by omitting the argument when calling GetOutput()
splitter.GetOutput()->Connect(filter2.GetInput());
// In order to connect aynchronous outputs, the
// output names need to be specified
splitter.GetOutput("out2")->Connect(filter3.GetInput());
splitter.GetOutput("out3")->Connect(filter4.GetInput());
- Home
- Libraries & components
- Download
- Compile (FAQ)
- Reference manual
- cisstCommon
- cisstVector
- cisstNumerical
- cisstOSAbstraction
- TBD
- cisstMultiTask
- cisstRobot
- cisstStereoVision
- Developers