KWIVER
stable
  • Introduction
  • Vital
    • Common Structures
    • Image Data Types and Related Algorithms
      • Image
      • Time Stamp
      • Image Container
      • Image I/O Algorithm
      • Convert Image Algorithm
      • Image Filter Algorithm
      • Split Image Algorithm
      • Video Input Algorithm
      • Code Example
    • Detector Data Types and Related Algorithms
    • Trackers
    • Activities
    • Configuration
  • Arrows
  • Sprokit
  • Tools
  • Tutorials
  • Extending Kwiver
KWIVER
  • »
  • Vital »
  • Image Data Types and Related Algorithms
  • Edit on GitHub

Image Data Types and Related Algorithms

Image

Warning

doxygenclass: Cannot find file: /home/docs/checkouts/readthedocs.org/user_builds/kwiver-fork/checkouts/stable/doc/manuals/_build/xml/index.xml

Time Stamp

Warning

doxygenclass: Cannot find file: /home/docs/checkouts/readthedocs.org/user_builds/kwiver-fork/checkouts/stable/doc/manuals/_build/xml/index.xml

Image Container

Warning

doxygenclass: Cannot find file: /home/docs/checkouts/readthedocs.org/user_builds/kwiver-fork/checkouts/stable/doc/manuals/_build/xml/index.xml

Image I/O Algorithm

Instantiate with:

kwiver::vital::algo::image_io_sptr img_io = kwiver::vital::algo::image_io::create("<impl_name>");

Arrow & Configuration

<impl_name> options

CMake Flag to Enable

OpenCV

ocv

KWIVER_ENABLE_OPENCV

VXL

vxl

KWIVER_ENABLE_VXL

Warning

doxygenclass: Cannot find file: /home/docs/checkouts/readthedocs.org/user_builds/kwiver-fork/checkouts/stable/doc/manuals/_build/xml/index.xml

Convert Image Algorithm

Instantiate with:

kwiver::vital::algo::convert_image_sptr img_bypas = kwiver::vital::algo::convert_image::create("<impl_name>");

Arrow & Configuration

<impl_name> options

CMake Flag to Enable

Core

bypass

KWIVER_ENABLE_ARROWS

Warning

doxygenclass: Cannot find file: /home/docs/checkouts/readthedocs.org/user_builds/kwiver-fork/checkouts/stable/doc/manuals/_build/xml/index.xml

Image Filter Algorithm

Instantiate with:

kwiver::vital::algo::image_filter_sptr img_filter = kwiver::vital::algo::image_filter::create("<impl_name>");

Arrow & Configuration

<impl_name> options

CMake Flag to Enable

N/A

N/A

N/A

** Currently there are no arrows implementing the image_filter algorithm **

Warning

doxygenclass: Cannot find file: /home/docs/checkouts/readthedocs.org/user_builds/kwiver-fork/checkouts/stable/doc/manuals/_build/xml/index.xml

Split Image Algorithm

Instantiate with:

kwiver::vital::algo::split_image_sptr img_split = kwiver::vital::algo::split_image::create("<impl_name>");

Arrow & Configuration

<impl_name> options

CMake Flag to Enable

OpenCV

ocv

KWIVER_ENABLE_OPENCV

VXL

vxl

KWIVER_ENABLE_VXL

Warning

doxygenclass: Cannot find file: /home/docs/checkouts/readthedocs.org/user_builds/kwiver-fork/checkouts/stable/doc/manuals/_build/xml/index.xml

Video Input Algorithm

Instantiate with:

kwiver::vital::algo::video_input_sptr img_bypas = kwiver::vital::algo::video_input::create("<impl_name>");

Arrow & Configuration

<impl_name> options

CMake Flag to Enable

VXL

vidl_ffmpeg

KWIVER_ENABLE_VXL

Warning

doxygenclass: Cannot find file: /home/docs/checkouts/readthedocs.org/user_builds/kwiver-fork/checkouts/stable/doc/manuals/_build/xml/index.xml

Code Example

  // These vital data types can then be used as inputs or outputs for algorithms.
  // The vital data types are a sort of common 'glue' between dispart algorithms allowing them to work together.

  // Image I/O algorithms are derived from the kwiver::vital::image_io algorithm interface

  // While we could instantiate a particular algorithm object directly with this code
  // kwiver::arrows::ocv::image_io ocv_io;
  // kwiver::arrows::vxl::image_io vxl_io;
  // This would require our application to include specific headers be include in our code
  // and require our application to directly link to OpenCV and cause a dependency

  // A key feature of the KWIVER architecture is the ability to dynamically load available algorithms at runtime.
  // This ability allow you to write your application with a set of basic data types and algorithm interfaces and
  // then dynamically replace or reconfigure algorithms at run time without needing to recompile
  // New algorithms can be dropped on disk at and KWIVER can run them
  // The first thing to do is to tell kwiver to load up all it's plugins (which includes all the algorithms)
  kwiver::vital::plugin_manager::instance().load_all_plugins();

  // Refer to this page : http://kwiver.readthedocs.io/en/latest/vital/images.html
  // Documenting the types and algorithms associated with images:
  //               Various implementations of the algorithm,
  //               The string to use to specify creation of a specific implementation,
  //               The KWIVER CMake option that builds the specific implementation

  ///////////////
  // Image I/O //
  ///////////////

  // The main image libraries used in KWIVER are the OpenCV and VXL libraries
  kwiver::vital::algo::image_io_sptr ocv_io = kwiver::vital::algo::image_io::create("ocv");
  kwiver::vital::algo::image_io_sptr vxl_io = kwiver::vital::algo::image_io::create("vxl");

  // The image_io interface is simple, and has a load and save method
  // These methods will operate on the vital object image_container
  // The image_container is intended to be a wrapper for image to facilitate conversion between
  // various representations. It provides limited access to the underlying
  // data and is not intended for direct use in image processing algorithms.
  kwiver::vital::image_container_sptr ocv_img = ocv_io->load("./cat.jpg");
  kwiver::vital::image_container_sptr vxl_img = vxl_io->load("./cat.jpg");

  // Let's use OpenCV to display the images
  // NOTE, this requires that our application CMakeLists properly find_package(OpenCV)
  // And that we tell our application CMake targets about OpenCV (See the CMakeLists.txt for this file)
  cv::Mat mat;
  // First, convert the image to an OpenCV image object
  mat = kwiver::arrows::ocv::image_container::vital_to_ocv(ocv_img->get_image(), kwiver::arrows::ocv::image_container::RGB_COLOR );
  cv::namedWindow("Image loaded by OpenCV", cv::WINDOW_AUTOSIZE);// Create a window for display.
  cv::imshow("Image loaded by OpenCV", mat);                     // Show our image inside it.
  cv::waitKey(5);
  kwiversys::SystemTools::Delay(2000);                                                   // Wait for 2s
  cv::destroyWindow("Image loaded by OpenCV");

  // We can do the same, even if the image was originally loaded with VXL
  mat = kwiver::arrows::ocv::image_container::vital_to_ocv(vxl_img->get_image(), kwiver::arrows::ocv::image_container::RGB_COLOR);
  cv::namedWindow("Image loaded by VXL", cv::WINDOW_AUTOSIZE);// Create a window for display.
  cv::imshow("Image loaded by VXL", mat);                     // Show our image inside it.
  cv::waitKey(5);
  kwiversys::SystemTools::Delay(2000);                                                // Wait for 2s
  cv::destroyWindow("Image loaded by VXL");

  //////////////////
  // Image Filter //
  //////////////////

  // Currently, there is no arrow implementing image filtering
  //kwiver::vital::algo::image_filter_sptr _filter = kwiver::vital::algo::image_filter::create("<impl_name>");

  /////////////////
  // Split Image //
  /////////////////

  // These algorithms split an image in half (left and right)
  kwiver::vital::algo::split_image_sptr ocv_split = kwiver::vital::algo::split_image::create("ocv");
  kwiver::vital::algo::split_image_sptr vxl_split = kwiver::vital::algo::split_image::create("vxl");

  std::vector<kwiver::vital::image_container_sptr> ocv_imgs = ocv_split->split(vxl_img);
  for (kwiver::vital::image_container_sptr i : ocv_imgs)
  {
    mat = kwiver::arrows::ocv::image_container::vital_to_ocv(i->get_image(), kwiver::arrows::ocv::image_container::RGB_COLOR);
    cv::namedWindow("OpenCV Split Image", cv::WINDOW_AUTOSIZE);// Create a window for display.
    cv::imshow("OpenCV Split Image", mat);                     // Show our image inside it.
    cv::waitKey(5);
    kwiversys::SystemTools::Delay(2000);                                               // Wait for 2s
    cv::destroyWindow("OpenCV Split Image");
  }

  std::vector<kwiver::vital::image_container_sptr> vxl_imgs = ocv_split->split(ocv_img);
  for (kwiver::vital::image_container_sptr i : vxl_imgs)
  {
    mat = kwiver::arrows::ocv::image_container::vital_to_ocv(i->get_image(), kwiver::arrows::ocv::image_container::RGB_COLOR);
    cv::namedWindow("VXL Split Image", cv::WINDOW_AUTOSIZE);// Create a window for display.
    cv::imshow("VXL Split Image", mat);                     // Show our image inside it.
    cv::waitKey(5);
    kwiversys::SystemTools::Delay(2000);                                            // Wait for 2s
    cv::destroyWindow("VXL Split Image");
  }

}
Previous Next

© Copyright 2020, Kitware, Inc.. Revision 6786e137.

Built with Sphinx using a theme provided by Read the Docs.