title: Converting 24bit RGB image to 8bit grayscale with opencv-node in node.js
body: <p>I'm trying to capture images within node.js from a webcam connected to a Raspberry Pi. Capturing works fine, but now when I want to transmit the images I have some serious problems with framerate and lags.</p>
  
  <p>Now my first idea was to convert the RGB images to 8bit grayscale, that should increase the performance by factor 3 (i hope..).</p>
  
  <p>I'm using node.js and opencv-node for this. Here you can see some code snippet for the moment:</p>
  
  <pre><code>var startT = new Date().getTime();
  var capture = new cv.VideoCapture();
  var frame = new cv.Mat;
  var grey = new cv.Mat;
  var imgPath = __dirname + "/ramdisk/";
  var frame_number = 0;
  
  capture.open(0);
  
  if (!capture.isOpened())
  {
      console.log("aCapLive could not open capture!");
      return;
  }
  
  function ImgCap()
  {
      var elapsed = (new Date().getTime() - startT) / 1000;
  
      capture.read(frame);
      cv.imwrite(imgPath+".bmp", frame);
  
      id = setImmediate(ImgCap);
  }
  
  ImgCap();
  </code></pre>
  
  <p>I tried to use something like</p>
  
  <pre><code>cv.cvtColor(frame, grey, "CV_BGR2GRAY");
  </code></pre>
  
  <p>after reading the image but i only get some TypeError saying that argument 2 has to be an integer... I dont know what to do at the moment. I referred to <a href="http://docs.opencv.org/doc/tutorials/introduction/load_save_image/load_save_image.html#explanation" rel="nofollow">http://docs.opencv.org/doc/tutorials/introduction/load_save_image/load_save_image.html#explanation</a> for converting a rgb to a grayscale image.</p>
  
  <p>Beside I'm still not sure if this just gives mit a 24bit grayscale image instead of 8bit..?!</p>
  
  <p>Thanks for any help in advance! :)</p>