Loading

OpenCV

Overview

OpenCV is a library of programming functions mainly aimed at real time computer vision, developed by Intel and now supported by Willow Garage. It is free for use under the open source BSD license. The library is cross-platform and focuses mainly on real-time image processing. If the library finds Intel's Integrated Performance Primitives on the system, it will use these commercial optimized routines to accelerate itself. Our cameras support this Vision Library.
 
We have created a sample OpenCV application with Ximea support. This application captures a video sequence and displays it on the screen, in OpenCV Mat format.
 

OpenCV Installation

The sample application for OpenCV Library requires the headers and binaries to be installed before it can be successfully built. Please follow these guidelines depending on your OS:

Sample application

To run this application, please follow these steps:

 
Sample application with XIMEA OpenCV Library is located:

  • Windows - in XIMEA\Examples\xiApiPlusOcv as a Visual Studio .vcxproj
  • Linux - in /opt/XIMEA/examples/xiApiPlusOpenCV directory as a Makefile project
  • OS X - in examples as a Makefile project

The Sample application uses the OpenCV xiApiPlusOcv.hpp library interface to capture series of frames from the camera and converts each frame to the OpenCV Mat format and shows it on the display. It uses a xiAPIplusCameraOcv class to handle the camera and its features.
 
When compiling on 64-bit Windows systems, the Solution platform in Visual Studio should be set to x64.
 

How to write applications

#include <stdio.h>
#include "xiApiPlusOcv.hpp" 

using namespace cv;
using namespace std;

int main (void)
{
 try
 {
   xiAPIplusCameraOcv cam;
   cam.OpenFirst();
   cam.SetExposureTime(10000); //10000 us = 10 ms
   cam.StartAcquisition();

   // Read and convert a frame from the camera
   Mat cv_mat_image = cam.GetNextImageOcvMat();
   // Show image on display
   cv::imshow("Image from camera",cv_mat_image);

   cam.StopAcquisition();
   cam.Close();
 }
 catch(xiAPIplus_Exception& exp)
 {
   exp.PrintError(); // report error if some call fails
 }
}

The xiAPIplusCameraOcv class is used to handle the camera. In an application an instance of this class has to be created. Then the class should be initialized by calling an opening method (e.g. OpenFirst()). Camera parameters can be set by calling set methods or read by calling get methods. The camera acquisition starts after StartAcquisition() is called. The captured frames can be read by calling GetNextImageOcvMat() - a method that reads a frame from the camera and converts it into OpenCV Mat format that can be directly used for OpenCV processing.

Documentation

Camera in OpenCV library

There is also legacy implementation of XIMEA API within OpenCV. Read mode here.