[Viame] Viame iamge i/o and python support
Linus Sherrill
linus.sherrill at kitware.com
Fri Sep 9 12:50:29 EDT 2016
1) How do we read/write/display images using opencv in VIAME? If you
have your own APIs handling data IO, it would be fine but we need to learn
how to convert formats, e.g., to cv::Mat.
Starting at the algorithm level, KWIVER provides image support using the
abstract base class kwiver::vital::image_container defined in
"vital/types/image_container.h". Implementations of this class provide
support for the actual image data. Since we have support for OpenCvV and
VXL, both those image formats are supported. Generally we are using the
Opencv image format. Image containers are passed via referecen using the
type "kwiver::vital::image_container_sptr".
As an example, the file
VIAME/source/packages/kwiver/arrows/ocv/hough_circle_detector.cxx accepts
an image container and extracts the cv::Mat. The following is the extracted
code snippet.
#include <arrows/ocv/image_container.h>
kwiver::vital::detected_object_set_sptr
hough_circle_detector::
detect( vital::image_container_sptr image_data) const
{
cv::Mat src = kwiver::arrows::ocv::image_container::vital_to_ocv(
image_data->get_image() );
...
An OpenCV image can be placed in an image container as shown in the
following code snippet.
#include <arrows/ocv/image_container.h>
vital::image_container_sptr
image_io
::load_(const std::string& filename) const
{
cv::Mat img = cv::imread(filename.c_str());
return vital::image_container_sptr(new
kwiver::arrows::ocv::image_container(img));
}
At the pipeline level, there are processes that read and write images.
frame_list_input: Reads a list of image file names and generates stream of
images and associated time stamps
image_file_reader: Reads an image file given the file name.
image_viewer: Display input image and delay
image_writer: Write image to disk.
There is a simple pipeline that reads an image and displays it.
VIAME/source/packages/kwiver/sprokit/pipelines/examples/image_reader.pipe
The image_object_detector process handles getting the image container from
the pipeline to the detector algorithm instance.
There is an example pipeline that runs the image_object_detector process in
the file
VIAME/source/packages/kwiver/sprokit/pipelines/examples/hough_detector/hough_detector.pipe
The code snippet shown below creates a process called "detector" as an
instance of "image_object_detector" and selects the detector type
"hough_circle_detector". What follows are the configuration parameters for
that algorithm.
process detector
:: image_object_detector
:detector:type hough_circle_detector
:detector:hough_circle_detector:dp 1
:detector:hough_circle_detector:min_dist 100
:detector:hough_circle_detector:param1 200
:detector:hough_circle_detector:param2 100
:detector:hough_circle_detector:min_radius 0
:detector:hough_circle_detector:max_radius 0
Similarly the scallop_tk detector could be selected using the following
code snippet
process detector
:: image_object_detector
:detector:type scallop_tk_detector
:detector:scallop_tk_detector:config_file config_location
The process name "detector" is the local name that is used when making
connections and could be something else if desired.
Note that the configuration items for a particular detector are all
prefixed with "detector:<detector-type>:". This allows you to keep inactive
configurations in the file when you are experimenting with different
algorithm implementations.
2) Our modules provide limited python APIs. I want to know how VIAME
called these APIs and pass data back and forth.
We have python wrappers for most of the vital types to allow python
processes to create the types that are passed in the pipeline. Currently we
do not have support to load concrete algorithms written in python.
The python process base class can be found at
VIAME/source/packages/kwiver/sprokit/processes/bindings/python/kwiver/kwiver_process.py.
This base class supports the process related traits. An example python
process can be found at
"VIAME/source/packages/kwiver/sprokit/processes/python/ApplyDescriptor.py"
Best regards,
-Linus
--
*Linus Sherrill - *Staff R&D Engineer
Kitware, Inc.
28 Corporate Drive
Clifton Park, NY 12065-8662
E: linus.sherrill at kitware.com
P: 518.881.4400
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/viame/attachments/20160909/4dfbb246/attachment.html>
More information about the Viame
mailing list