OpenCV

Open Computer Vision

OpenCV (Open Source Computer Vision Library) is an open source computer vision and machine learning software library.

OpenCV was built to provide a common infrastructure for computer vision applications and to accelerate the use of machine perception in the commercial products.

Χρησεις

  • Υπολογισμοί με βάση τη θέση της κάμερας
  • Αναγνώριση προσώπου
  • Αναγνώριση κινήσεων
  • Human–computer interaction (HCI)
  • Κινητά ρομπότ
  • Ταυτοποίηση Αντικειμένων
  • Στερεοσκοπική οπτική
  • Παρακολούθηση κίνησης
  • Επαυξημένη πραγματικότητα

Λόγο των δυνατοτήτων του, το OpenCV υποστηρίζεται σχεδόν σε όλες τις διαθέσιμες πλατφόρμες

Desktop

  • Linux
  • Mac OS X
  • Windows
  • FreeBSD
  • OpenBSD

Mobile

  • Android
  • iOS
  • Windows
  • Blackberry 10
  • Maemo

Find track boundaries

Read QR Codes

Find objects…

and people

Programming Languages

  • C++
  • C
  • Python
  • Java
  • MATLAB
  • CUDA
  • OpenCL

Examples

Basics

Imports


import cv2                                  # OpenCV functions
import cv2.cv as cv                          # Older OpenCV functions
from sensor_msgs.msg import Image, CameraInfo # ROS related
from cv_bridge import CvBridge, CvBridgeError  # Bridge from ROS to OpenCV
import numpy as np                              # Math library for image processing
                

Create window


self.cv_window_name = self.node_name2
cv.NamedWindow(self.cv_window_name, cv.CV_WINDOW_NORMAL)
cv.MoveWindow(self.cv_window_name, 25, 75)
                

Create a subscriber


self.image_sub = rospy.Subscriber("/camera/rgb/image_color", 
                      Image, self.image_callback)
                

From ROS Obj to OpenCV Obj


def image_callback(self, ros_image):
    # Use cv_bridge() to convert the ROS image to OpenCV format 
    try:
        frame = self.bridge.imgmsg_to_cv(ros_image, "bgr8") 
    except CvBridgeError, e:
        print e
                

Convert to Numpy array


frame = np.array(frame, dtype=np.uint8)
                

Proccess image


def process_image(self, frame):
    # Convert to greyscale
    grey = cv2.cvtColor(frame, cv.CV_BGR2GRAY)

    # Blur the image
    grey = cv2.blur(grey, (7, 7))4

     # Compute edges using the Canny edge filter
    edges = cv2.Canny(grey, 15.0, 30.0)

    return edges
                

Whole Demo


fork here:
https://bitbucket.org/tsagi/pol_vision

The end


@tsagi

OpenCV Polymechanon

By Tasos Sangiotis

OpenCV Polymechanon

  • 981