title: OpenCV Assertion failed error
body: <p>I am working on a project which requires face recognition and prediction. When I upload an image, it should recognize the person from the database.I am trying to implement using Nodejs and OpenCV.
  My code looks like this:</p>
  
  <pre><code>var FaceRecognizer = new cv.FaceRecognizer();
  var uploadDir = joinPath(__dirname, "/images");
  var fileDir = joinPath(__dirname, "/uploads");
  var cvImages = [];
  
  
  fs.readdir(uploadDir, function(err, files){
  if(err){
      throw new Error(err);
  
  }
  if(files.length &gt; 0){ //There are some user related image folders
      files.forEach(function(subfolder, index, array){
          if(subfolder != ".DS_Store" ){ //Issue with Mac, test on Linux-VM
              //We are now iterating over each subfolder
              var subFolderDir = joinPath(uploadDir, "/"+"subfolder");
              var images = fs.readdirSync(subFolderDir);
              images.forEach(function(image, index, array){//Get Matrix Objekt for each image to train OpenCV
                  if(image != ".DS_Store"){
                      var imageDir = joinPath(subFolderDir, "/"+image);
  
                      cv.readImage(imageDir, function(err, im){
                          var channels = im.channels();
                          if(channels &gt;=3){
  
                              var labelNumber = parseInt(Math.floor((Math.random()* 10)+1)); //Create labelnumber; Account-Id starts by 1, labels for openCV start with 0
                              cvImages.push(new Array(labelNumber,im));  //Add image to Array
                          }
                      });
                  }
              });
          }
      });
      if(cvImages.length &gt; 3){
          console.log("Training images (we have at least 3 images)", cvImages);
          FaceRecognizer.trainSync(cvImages);
          cv.readImage(fileDir, function(err, im){
  
              if(err) res.send(err);
              var whoisit = FaceRecognizer.predictSync(im);
              console.log("Identified image", whoisit);
          })
      }else{
          console.log("Not enough images uploaded yet", cvImages);
      }
  }else{
      console.log("There are no images uploaded yet!");
  }
  });
  </code></pre>
  
  <p>I am getting this error:</p>
  
  <pre><code>OpenCV Error: Assertion failed (s &gt;= 0) in setSize, file /build/opencv-SviWsf/opencv-2.4.9.1+dfsg/modules/core/src/matrix.cpp, line 116
  terminate called after throwing an instance of 'cv::Exception'
    what():  /build/opencv-SviWsf/opencv-2.4.9.1+dfsg/modules/core/src/matrix.cpp:116: error: (-215) s &gt;= 0 in function setSize
  
  Aborted (core dumped)
  </code></pre>
  
  <p>Can anyone suggest any possible solution?</p>