@@ -263,7 +263,7 @@ public boolean getUseColor(){
263263 return useColor ;
264264 }
265265
266- private Mat getCurrentBuffer (){
266+ private Mat getCurrentMat (){
267267 if (useROI ){
268268 return matROI ;
269269
@@ -345,7 +345,7 @@ public void loadCascade(String cascadeFileName){
345345
346346 public Rectangle [] detect (){
347347 MatOfRect detections = new MatOfRect ();
348- classifier .detectMultiScale (getCurrentBuffer (), detections );
348+ classifier .detectMultiScale (getCurrentMat (), detections );
349349
350350 Rect [] rects = detections .toArray ();
351351
@@ -362,8 +362,8 @@ public void startBackgroundSubtraction(int history, int nMixtures, double backgr
362362 }
363363
364364 public void updateBackground (){
365- Mat foreground = imitate (getCurrentBuffer ());
366- backgroundSubtractor .apply (getCurrentBuffer (), foreground , 0.05 );
365+ Mat foreground = imitate (getCurrentMat ());
366+ backgroundSubtractor .apply (getCurrentMat (), foreground , 0.05 );
367367 setGray (foreground );
368368 }
369369
@@ -384,7 +384,7 @@ public void contrast(float amt){
384384 modifier = new Scalar (amt );
385385 }
386386
387- Core .multiply (getCurrentBuffer (), modifier , getCurrentBuffer ());
387+ Core .multiply (getCurrentMat (), modifier , getCurrentMat ());
388388 }
389389
390390 /**
@@ -394,7 +394,7 @@ public void contrast(float amt){
394394 * A PVector with the location of the maximum value.
395395 */
396396 public PVector max (){
397- MinMaxLocResult r = Core .minMaxLoc (getCurrentBuffer ());
397+ MinMaxLocResult r = Core .minMaxLoc (getCurrentMat ());
398398 return OpenCV .pointToPVector (r .maxLoc );
399399 }
400400
@@ -405,7 +405,7 @@ public PVector max(){
405405 * A PVector with the location of the minimum value.
406406 */
407407 public PVector min (){
408- MinMaxLocResult r = Core .minMaxLoc (getCurrentBuffer ());
408+ MinMaxLocResult r = Core .minMaxLoc (getCurrentMat ());
409409 return OpenCV .pointToPVector (r .minLoc );
410410 }
411411
@@ -430,7 +430,7 @@ public void brightness(int amt){
430430 modifier = new Scalar (amt );
431431 }
432432
433- Core .add (getCurrentBuffer (), modifier , getCurrentBuffer ());
433+ Core .add (getCurrentMat (), modifier , getCurrentMat ());
434434 }
435435
436436 public static Mat imitate (Mat m ){
@@ -442,16 +442,16 @@ public void diff(PImage img){
442442 Mat imgMat = imitate (getColor ());
443443 toCv (img , imgMat );
444444
445- Mat dst = imitate (getCurrentBuffer ());
445+ Mat dst = imitate (getCurrentMat ());
446446
447447 if (useColor ){
448448 ARGBtoBGRA (imgMat , imgMat );
449- Core .absdiff (getCurrentBuffer (), imgMat , dst );
449+ Core .absdiff (getCurrentMat (), imgMat , dst );
450450 } else {
451- Core .absdiff (getCurrentBuffer (), OpenCV .gray (imgMat ), dst );
451+ Core .absdiff (getCurrentMat (), OpenCV .gray (imgMat ), dst );
452452 }
453453
454- dst .assignTo (getCurrentBuffer ());
454+ dst .assignTo (getCurrentMat ());
455455 }
456456
457457 public static void diff (Mat mat1 , Mat mat2 ){
@@ -461,58 +461,58 @@ public static void diff(Mat mat1, Mat mat2){
461461 }
462462
463463 public void threshold (int threshold ){
464- Imgproc .threshold (getCurrentBuffer (), getCurrentBuffer (), threshold , 255 , Imgproc .THRESH_BINARY );
464+ Imgproc .threshold (getCurrentMat (), getCurrentMat (), threshold , 255 , Imgproc .THRESH_BINARY );
465465 }
466466
467467 public void adaptiveThreshold (int blockSize , int c ){
468468 try {
469- Imgproc .adaptiveThreshold (getCurrentBuffer (), getCurrentBuffer (), 255 , Imgproc .ADAPTIVE_THRESH_GAUSSIAN_C , Imgproc .THRESH_BINARY , blockSize , c );
469+ Imgproc .adaptiveThreshold (getCurrentMat (), getCurrentMat (), 255 , Imgproc .ADAPTIVE_THRESH_GAUSSIAN_C , Imgproc .THRESH_BINARY , blockSize , c );
470470 } catch (CvException e ){
471471 PApplet .println ("ERROR: adaptiveThreshold function only works on gray images." );
472472 }
473473 }
474474
475475 public void equalizeHistogram (){
476476 try {
477- Imgproc .equalizeHist (getCurrentBuffer (), getCurrentBuffer ());
477+ Imgproc .equalizeHist (getCurrentMat (), getCurrentMat ());
478478 } catch (CvException e ){
479479 PApplet .println ("ERROR: equalizeHistogram only works on a gray image." );
480480 }
481481 }
482482
483483 public void invert (){
484- Core .bitwise_not (getCurrentBuffer (),getCurrentBuffer ());
484+ Core .bitwise_not (getCurrentMat (),getCurrentMat ());
485485 }
486486
487487 public void dilate (){
488- Imgproc .dilate (getCurrentBuffer (), getCurrentBuffer (), new Mat ());
488+ Imgproc .dilate (getCurrentMat (), getCurrentMat (), new Mat ());
489489 }
490490
491491 public void erode (){
492- Imgproc .erode (getCurrentBuffer (), getCurrentBuffer (), new Mat ());
492+ Imgproc .erode (getCurrentMat (), getCurrentMat (), new Mat ());
493493 }
494494
495495 public void blur (int blurSize ){
496- Imgproc .blur (getCurrentBuffer (), getCurrentBuffer (), new Size (blurSize , blurSize ));
496+ Imgproc .blur (getCurrentMat (), getCurrentMat (), new Size (blurSize , blurSize ));
497497 }
498498
499499 public void findCannyEdges (int lowThreshold , int highThreshold ){
500- Imgproc .Canny (getCurrentBuffer (), getCurrentBuffer (), lowThreshold , highThreshold );
500+ Imgproc .Canny (getCurrentMat (), getCurrentMat (), lowThreshold , highThreshold );
501501 }
502502
503503 public void findSobelEdges (int dx , int dy ){
504- Mat sobeled = new Mat (getCurrentBuffer ().height (), getCurrentBuffer ().width (), CvType .CV_32F );
505- Imgproc .Sobel (getCurrentBuffer (), sobeled , CvType .CV_32F , dx , dy );
506- sobeled .convertTo (getCurrentBuffer (), getCurrentBuffer ().type ());
504+ Mat sobeled = new Mat (getCurrentMat ().height (), getCurrentMat ().width (), CvType .CV_32F );
505+ Imgproc .Sobel (getCurrentMat (), sobeled , CvType .CV_32F , dx , dy );
506+ sobeled .convertTo (getCurrentMat (), getCurrentMat ().type ());
507507 }
508508
509509 public void findScharrEdges (int direction ){
510510 if (direction == HORIZONTAL ){
511- Imgproc .Scharr (getCurrentBuffer (), getCurrentBuffer (), -1 , 1 , 0 );
511+ Imgproc .Scharr (getCurrentMat (), getCurrentMat (), -1 , 1 , 0 );
512512 }
513513
514514 if (direction == VERTICAL ){
515- Imgproc .Scharr (getCurrentBuffer (), getCurrentBuffer (), -1 , 0 , 1 );
515+ Imgproc .Scharr (getCurrentMat (), getCurrentMat (), -1 , 0 , 1 );
516516 }
517517 }
518518
@@ -527,7 +527,7 @@ public ArrayList<Contour> findContours(boolean findHoles, boolean sort){
527527 try {
528528 int contourFindingMode = (findHoles ? Imgproc .RETR_LIST : Imgproc .RETR_EXTERNAL );
529529
530- Imgproc .findContours (getCurrentBuffer (), contourMat , new Mat (), contourFindingMode , Imgproc .CHAIN_APPROX_NONE );
530+ Imgproc .findContours (getCurrentMat (), contourMat , new Mat (), contourFindingMode , Imgproc .CHAIN_APPROX_NONE );
531531 } catch (CvException e ){
532532 PApplet .println ("ERROR: findContours only works with a gray image." );
533533 }
@@ -544,14 +544,14 @@ public ArrayList<Contour> findContours(boolean findHoles, boolean sort){
544544
545545 public ArrayList <PVector > findChessboardCorners (int patternWidth , int patternHeight ){
546546 MatOfPoint2f corners = new MatOfPoint2f ();
547- Calib3d .findChessboardCorners (getCurrentBuffer (), new Size (patternWidth ,patternHeight ), corners );
547+ Calib3d .findChessboardCorners (getCurrentMat (), new Size (patternWidth ,patternHeight ), corners );
548548 return matToPVectors (corners );
549549 }
550550
551551 /**
552552 *
553- * @param buffer
554- * The buffer from which to calculate the histogram. Get this from getBufferGray (), getBufferR (), getBufferG (), or getBufferB() .
553+ * @param mat
554+ * The mat from which to calculate the histogram. Get this from getGray (), getR (), getG (), getB(), etc. .
555555 * 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.
556556 * @param numBins
557557 * The number of bins into which divide the histogram should be divided.
@@ -560,12 +560,12 @@ public ArrayList<PVector> findChessboardCorners(int patternWidth, int patternHei
560560 * @return
561561 * A Histogram object that you can call draw() on.
562562 */
563- public Histogram findHistogram (Mat buffer , int numBins ){
564- return findHistogram (buffer , numBins , true );
563+ public Histogram findHistogram (Mat mat , int numBins ){
564+ return findHistogram (mat , numBins , true );
565565 }
566566
567567
568- public Histogram findHistogram (Mat buffer , int numBins , boolean normalize ){
568+ public Histogram findHistogram (Mat mat , int numBins , boolean normalize ){
569569
570570 MatOfInt channels = new MatOfInt (0 );
571571 MatOfInt histSize = new MatOfInt (numBins );
@@ -574,7 +574,7 @@ public Histogram findHistogram(Mat buffer, int numBins, boolean normalize){
574574 Mat hist = new Mat ();
575575
576576 ArrayList <Mat > images = new ArrayList <Mat >();
577- images .add (buffer );
577+ images .add (mat );
578578
579579 Imgproc .calcHist ( images , channels , new Mat (), hist , histSize , ranges );
580580
@@ -583,7 +583,6 @@ public Histogram findHistogram(Mat buffer, int numBins, boolean normalize){
583583 }
584584
585585 return new Histogram (parent , hist );
586-
587586 }
588587
589588 /**
@@ -596,7 +595,7 @@ public Histogram findHistogram(Mat buffer, int numBins, boolean normalize){
596595 * @param upperBound
597596 */
598597 public void inRange (int lowerBound , int upperBound ){
599- Core .inRange (getCurrentBuffer (), new Scalar (lowerBound ), new Scalar (upperBound ), getCurrentBuffer ());
598+ Core .inRange (getCurrentMat (), new Scalar (lowerBound ), new Scalar (upperBound ), getCurrentMat ());
600599 }
601600
602601 /**
0 commit comments