|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgab.opencv.OpenCV
public class OpenCV
This is a template class and can be used to start a new processing library or tool. Make sure you rename this class as well as the name of the example package 'template' to your own library or tool naming convention.
Field Summary | |
---|---|
static String |
CASCADE_CLOCK
|
static String |
CASCADE_EYE
|
static String |
CASCADE_FRONTALFACE
|
static String |
CASCADE_FULLBODY
|
static String |
CASCADE_LOWERBODY
|
static String |
CASCADE_MOUTH
|
static String |
CASCADE_NOSE
|
static String |
CASCADE_PEDESTRIAN
|
static String |
CASCADE_PEDESTRIANS
|
static String |
CASCADE_PROFILEFACE
|
static String |
CASCADE_RIGHT_EAR
|
static String |
CASCADE_UPPERBODY
|
CascadeClassifier |
classifier
|
int |
colorSpace
|
int |
height
|
static int |
HORIZONTAL
|
Mat |
matA
|
Mat |
matB
|
Mat |
matBGRA
|
Mat |
matG
|
Mat |
matGray
|
Mat |
matH
|
Mat |
matHSV
|
Mat |
matR
|
Mat |
matROI
|
Mat |
matS
|
Mat |
matV
|
Mat |
nonROImat
|
static String |
VERSION
|
static int |
VERTICAL
|
int |
width
|
Constructor Summary | |
---|---|
OpenCV(PApplet theParent,
int width,
int height)
Initialize OpenCV with a width and height. |
|
OpenCV(PApplet theParent,
PImage img)
Initialize OpenCV with an image. |
|
OpenCV(PApplet theParent,
PImage img,
boolean useColor)
Initialize OpenCV with an image. |
|
OpenCV(PApplet theParent,
String pathToImg)
Initialize OpenCV with the path to an image. |
|
OpenCV(PApplet theParent,
String pathToImg,
boolean useColor)
Initialize OpenCV with the path to an image. |
Method Summary | |
---|---|
void |
adaptiveThreshold(int blockSize,
int c)
|
static void |
ARGBtoBGRA(Mat rgba,
Mat bgra)
|
void |
blur(int blurSize)
|
void |
blur(int blurW,
int blurH)
|
void |
brightness(int amt)
Adjust the brightness of the image. |
void |
contrast(float amt)
Adjust the contrast of the image. |
Rectangle[] |
detect()
|
static void |
diff(Mat mat1,
Mat mat2)
|
void |
diff(PImage img)
|
void |
dilate()
|
void |
equalizeHistogram()
|
void |
erode()
|
void |
findCannyEdges(int lowThreshold,
int highThreshold)
|
ArrayList<PVector> |
findChessboardCorners(int patternWidth,
int patternHeight)
|
ArrayList<Contour> |
findContours()
|
ArrayList<Contour> |
findContours(boolean findHoles,
boolean sort)
|
Histogram |
findHistogram(Mat mat,
int numBins)
|
Histogram |
findHistogram(Mat mat,
int numBins,
boolean normalize)
|
ArrayList<Line> |
findLines(int threshold,
double minLineLength,
double maxLineGap)
|
void |
findScharrEdges(int direction)
|
void |
findSobelEdges(int dx,
int dy)
|
Mat |
getA()
|
Mat |
getB()
|
Mat |
getColor()
|
int |
getColorSpace()
|
Mat |
getG()
|
Mat |
getGray()
|
Mat |
getH()
|
PImage |
getInput()
|
PImage |
getOutput()
|
Mat |
getR()
|
Mat |
getROI()
|
Mat |
getS()
|
int |
getSize()
|
PImage |
getSnapshot()
|
PImage |
getSnapshot(Mat m)
|
boolean |
getUseColor()
|
Mat |
getV()
|
void |
gray()
|
static Mat |
gray(Mat src)
|
static Mat |
imitate(Mat m)
|
void |
inRange(int lowerBound,
int upperBound)
Filter the image for values between a lower and upper bound. |
void |
invert()
|
void |
loadCascade(String cascadeFileName)
load a cascade xml file from the data folder NB: ant build scripts copy the data folder outside of the jar so that this will work. |
void |
loadImage(PImage img)
|
void |
loadImage(String imgPath)
Load an image from a path. |
static ArrayList<PVector> |
matToPVectors(MatOfPoint mat)
|
static ArrayList<PVector> |
matToPVectors(MatOfPoint2f mat)
|
String |
matToS(Mat mat)
|
PVector |
max()
Get the x-y location of the maximum value in the current image. |
PVector |
min()
Get the x-y location of the minimum value in the current image. |
static PVector |
pointToPVector(Point p)
|
void |
releaseROI()
|
void |
setColor(Mat m)
|
void |
setGray(Mat m)
|
boolean |
setROI(int x,
int y,
int w,
int h)
|
void |
startBackgroundSubtraction(int history,
int nMixtures,
double backgroundRatio)
|
void |
threshold(int threshold)
|
static void |
toCv(PImage img,
Mat m)
Convert a Processing PImage to an OpenCV Mat. |
void |
toPImage(Mat m,
PImage img)
Convert an OpenCV Mat object into a PImage to be used in other Processing code. |
void |
updateBackground()
|
void |
useColor()
Apply subsequent image processing to the color version of the loaded image. |
void |
useColor(int colorSpace)
|
void |
useGray()
|
static String |
version()
return the version of the library. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public int width
public int height
public Mat matBGRA
public Mat matR
public Mat matG
public Mat matB
public Mat matA
public Mat matHSV
public Mat matH
public Mat matS
public Mat matV
public Mat matGray
public Mat matROI
public Mat nonROImat
public int colorSpace
public CascadeClassifier classifier
public static final String VERSION
public static final String CASCADE_FRONTALFACE
public static final String CASCADE_PEDESTRIANS
public static final String CASCADE_EYE
public static final String CASCADE_CLOCK
public static final String CASCADE_NOSE
public static final String CASCADE_MOUTH
public static final String CASCADE_UPPERBODY
public static final String CASCADE_LOWERBODY
public static final String CASCADE_FULLBODY
public static final String CASCADE_PEDESTRIAN
public static final String CASCADE_RIGHT_EAR
public static final String CASCADE_PROFILEFACE
public static final int HORIZONTAL
public static final int VERTICAL
Constructor Detail |
---|
public OpenCV(PApplet theParent, String pathToImg)
theParent
- - A PApplet representing the user sketch, i.e "this"pathToImg
- - A String with a path to the image to be loadedpublic OpenCV(PApplet theParent, String pathToImg, boolean useColor)
theParent
- - A PApplet representing the user sketch, i.e "this"pathToImg
- - A String with a path to the image to be loadeduseColor
- - (Optional) Set to true if you want to use the color version of the image for processing.public OpenCV(PApplet theParent, PImage img)
theParent
- A PApplet representing the user sketch, i.e "this"img
- A PImage to be loadedpublic OpenCV(PApplet theParent, PImage img, boolean useColor)
theParent
- A PApplet representing the user sketch, i.e "this"img
- A PImage to be loadeduseColor
- (Optional) Set to true if you want to use the color version of the image for processing.public OpenCV(PApplet theParent, int width, int height)
theParent
- A PApplet representing the user sketch, i.e "this"width
- intheight
- intMethod Detail |
---|
public void useColor()
public int getColorSpace()
public void useColor(int colorSpace)
public void useGray()
public boolean getUseColor()
public void loadCascade(String cascadeFileName)
cascadeFileName
- public Rectangle[] detect()
public void startBackgroundSubtraction(int history, int nMixtures, double backgroundRatio)
public void updateBackground()
public void contrast(float amt)
amt
- Amount of contrast to apply. 0-1.0 reduces contrast. Above 1.0 increases contrast.public PVector max()
public PVector min()
public static PVector pointToPVector(Point p)
public void brightness(int amt)
amt
- The amount to brighten the image. Ranges -255 to 255.public static Mat imitate(Mat m)
public void diff(PImage img)
public static void diff(Mat mat1, Mat mat2)
public void threshold(int threshold)
public void adaptiveThreshold(int blockSize, int c)
public void equalizeHistogram()
public void invert()
public void dilate()
public void erode()
public void blur(int blurSize)
public void blur(int blurW, int blurH)
public void findCannyEdges(int lowThreshold, int highThreshold)
public void findSobelEdges(int dx, int dy)
public void findScharrEdges(int direction)
public ArrayList<Contour> findContours()
public ArrayList<Contour> findContours(boolean findHoles, boolean sort)
public ArrayList<Line> findLines(int threshold, double minLineLength, double maxLineGap)
public ArrayList<PVector> findChessboardCorners(int patternWidth, int patternHeight)
public Histogram findHistogram(Mat mat, int numBins)
mat
- The mat from which to calculate the histogram. Get this from getGray(), getR(), getG(), getB(), etc..
By default this will normalize the histogram (scale the values to 0.0-1.0). Pass false as the third argument to keep values unormalized.numBins
- The number of bins into which divide the histogram should be divided.normalize
- (optional)
Whether or not to normalize the histogram (scale the values to 0.0-1.0). Defaults to true.
public Histogram findHistogram(Mat mat, int numBins, boolean normalize)
public void inRange(int lowerBound, int upperBound)
lowerBound
- upperBound
- public static Mat gray(Mat src)
src
- A Mat of type 8UC4 with channels arranged as BGRA.
public void gray()
public boolean setROI(int x, int y, int w, int h)
public void releaseROI()
public void loadImage(String imgPath)
imgPath
- String with the path to the imagepublic void loadImage(PImage img)
public static void ARGBtoBGRA(Mat rgba, Mat bgra)
public int getSize()
public void toPImage(Mat m, PImage img)
m
- A Mat you want convertedimg
- The PImage you want the Mat converted into.public static void toCv(PImage img, Mat m)
img
- The PImage to convert.m
- The Mat to receive the image data.public static ArrayList<PVector> matToPVectors(MatOfPoint mat)
public static ArrayList<PVector> matToPVectors(MatOfPoint2f mat)
public String matToS(Mat mat)
public PImage getInput()
public PImage getOutput()
public PImage getSnapshot()
public PImage getSnapshot(Mat m)
public Mat getR()
public Mat getG()
public Mat getB()
public Mat getA()
public Mat getH()
public Mat getS()
public Mat getV()
public Mat getGray()
public void setGray(Mat m)
public void setColor(Mat m)
public Mat getColor()
public Mat getROI()
public static String version()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |