예제 #1
0
int IPS_simple::processLaplacian(){
    //Raw Image
    Mat src = imread( Constants::IMG_RAW );
    if (!src.data) return 1;
    Mat dst = applyLaplacian(src);
    imwrite( Constants::IMG_RAW_LAPLACE, dst );

    //Ref Image
    src = imread( Constants::IMG_REF );
    if (!src.data) return 1;
    dst = applyLaplacian(src);
    imwrite( Constants::IMG_REF_LAPLACE, dst );
    return 0;
}
예제 #2
0
int main(int argc,char* argv[] )
{
  //!< In this variable the current frame is stored
  cv::Mat frame;
  cv::Mat sobel;
  cv::Mat canny;
  cv::Mat gray;
  cv::Mat scharr;
  cv::Mat laplacian;

  std::string displayWindow("Display");

  int cam;
  bool exitVal = false ;

  if ( argc <= 1) {
    std::cout << "Usage : ./camera CAM_NUM" << std::endl;
    std::cout << "CAM_NUM is the camera we wish to open!" << std::endl;
    std::cout << "Default Laptop Camera will be opened!" << std::endl;
    cam = 0;
  }
  else
    cam = atoi(argv[1]);

  cv::VideoCapture camera(cam);
  if (!camera.isOpened()) {
    std::cout << "Cannot open the video file" << std::endl;
    return -1;
  }
  int KeyPressed=255; 
  int i=0;
  std::cout << "Press esc if you want to stop the process" << std::endl;

  char state;
  while (true) {
    camera.grab();
    camera.retrieve(frame);
    cv::imshow("BGR colorspace", frame);

    //!< Apply Sobel edge detections algorithm
    applySobel (frame, &sobel);
    cv::imshow("Sobel algorithm", sobel);

    //!< Apply Canny edge detection algorithm
    cvtColor( frame, gray, CV_BGR2GRAY );
    applyCanny( gray, &canny);
    cv::imshow("Canny algorithm", canny);

    //!< Apply Scharr edge detection algorithm
    applyScharr (frame, &scharr);
    cv::imshow("Scharr algorithm", scharr);

    //!< Apply laplacian edge detection algorithm
    applyLaplacian (frame, &laplacian);
    cv::imshow("Laplacian algorithm", laplacian);
    KeyPressed=cvWaitKey(10) & 255; //!< wait for 'esc' key press for 10 ms

    switch (KeyPressed) {
      case (char)27:
        exitVal = true;
        break;
      default:
        break;
    }

    if (exitVal) //!< KeyPressed==esc
        break;
  }
}