Up | OpenCV 2.3 | OpenCV 2.2 | OpenCV 1.1

 

  

 
OpenCV 2.2

Requirements to use OpenCV with Scorpion 8

To use OpenCV in Scorpion Vision you must follow the Python 2.6 installation guide.

OpenCV 2.2 setup

There are some additional requirements for OpenCV 2.2

  • Install numpy (1.5.1) from http://new.scipy.org/download.html
  • Install OpenCV 2.2
  • Make sure that OpenCV "bin" folder is added to system environment path variable (it can be selected when installing or added later via advanced system settings). Default installation would be "C:\OpenCV2.2\bin"
  • Download Python 2.6 wrapper for OpenCV 2.2 here
  • Unzip python 2.6 wrapper for OpenCV 2.2 into OpenCV installation folder (or any other accessible location)

OcvImage - Scorpion helper class to use OpenCV

The OcvImage python module is located here for OpenCV 2.1 and 2.2.

Sample profiles with OpenCV 2.2

Note: For OpenCV 2.1 and 2.2 use import cv

Note2:

  • For OpenCV 2.2 samples paths to OpenCV library are set to fixed location
    • C:\OpenCV2.2\Python2.6\Lib\site-packages.
    • Make sure it points to correct location on your machine.

Example 1: ScriptTool cvAdaptiveThreshold

from OcvImage21 import OcvImage
import cv

objectImage = OcvImage(GetTool(GetCurSource()).imageNo)
object = objectImage.GetCvImage()

try:
  #Example of a useful transform - adaptive threshold
  #AdaptiveThreshold(im,im2,max_value,adaptive_method,threshold_type,block_size,offset)
  #apply to OpenCV image, can be done in place
  cv.AdaptiveThreshold(object,object,125,cv.CV_ADAPTIVE_THRESH_MEAN_C,cv.CV_THRESH_BINARY_INV,7,10)

  #can apply morphology if desired,
  # - again safe to do in place or could make second image
  cv.Dilate(object,object,None,1)

  # cv.Erode(object,object,None,2)

  OcvImage().Assign(object, "Output")
except Exception, msg:
  print msg

Example 2: Adding Canny Filter

#the script reside inside a Scorpion ScriptToolfrom OcvImage21 import OcvImage
import cv

objectImage = OcvImage(GetTool(GetCurSource()).imageNo)
object = objectImage.GetCvImage()

try:
  cv.Canny(object, object,40, 60,3)
  OcvImage().Assign(object, "Output")
except Exception, msg:
  print msg

Internet Resources on OpenCV with Python

 

Scorpion Vision Version XII : Build 646 - Date: 20170225
Scorpion Vision Software® is a registered trademark of Tordivel AS.
Copyright © 2000 - 2017 Tordivel AS.