Getting started with OpenCV

edited March 2018 in Kinect


I would like to have a go with some of OpenCV function but I am stuck right at the beginning... I Imported the library (via tools>Add tools>libraries>OpenCV for Processing) then I copied this code from GitHub (changing the name of the jpg file of course) :

import gab.opencv.*;

OpenCV opencv;
ArrayList<Line> lines;

void setup() {
  PImage src = loadImage("test_foot.jpg");
  src.resize(0, 800);
  size(796, 800);

  opencv = new OpenCV(this, src);
  opencv.findCannyEdges(20, 75);

  // Find lines with Hough line detection
  // Arguments are: threshold, minLengthLength, maxLineGap
  lines = opencv.findLines(100, 30, 20);

void draw() {
  image(opencv.getOutput(), 0, 0);

  for (Line line : lines) {
    // lines include angle in radians, measured in double precision
    // so we can select out vertical and horizontal lines
    // They also include "start" and "end" PVectors with the position
    if (line.angle >= radians(0) && line.angle < radians(1)) {
      stroke(0, 255, 0);
      line(line.start.x, line.start.y, line.end.x, line.end.y);

    if (line.angle > radians(89) && line.angle < radians(91)) {
      stroke(255, 0, 0);
      line(line.start.x, line.start.y, line.end.x, line.end.y);

I get fours lines of code underlined in red with the following messages:

The constructor "OpenCV(OpenCV, Image)" does not exist The function "findCannyEdges(int,int,int)" does not exist The function "findLines(int,int,int)" does not exist The function "getOutput()" does not exist

So it seems to me that the library was not imported properly how do I correct that ? Is there any other library/tool I should import too ?

Thanks !



  • Answer ✓

    well, I opened another exemple file, which worked fine even though it contained the same OpenCV constructor. (so the library was indeed imported) I copied the first code into the second sketch and it worked... no explanation

Sign In or Register to comment.