
        
// Auto-generated C Code - S2i Mosaicode
/*
*	In order to compile this source code run, in a terminal window, the following command:
*	gcc sourceCodeName.c `pkg-config --libs --cflags opencv` -o outputProgramName
*
*	the `pkg-config ... opencv` parameter is a inline command that returns the path to both
*	the libraries and the headers necessary when using opencv. The command also returns other necessary compiler options.
*/

#ifdef _CH_
#pragma package <opencv>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include "opencv2/core.hpp"
#include "opencv2/opencv.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/objdetect.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/features2d/features2d.hpp"

using namespace cv;
using namespace std;

#define FRAMERATE 1000.0 / 25.0


int main(int argc, char ** argv){
    char key = ' ';
            
    Mat image_file_14_output_image;
        
    Mat blurred_face_23_input_image;
    int blurred_face_23_input_integer1 = 8;
    int blurred_face_23_input_integer2 = 8;
    Mat blurred_face_23_output_image;
    Mat tmp23;
    CascadeClassifier face_cascade_23;
    vector<Rect> faces_23;
        
    Mat show_image_4_input_image;
    if(strcmp("WINDOW_NORMAL", "WINDOW_AUTOSIZE") == 0)
        namedWindow("My Image", WINDOW_NORMAL);
    else
        namedWindow("My Image", WINDOW_AUTOSIZE);

    while((key = (char)waitKey(FRAMERATE)) != 27){
        
    image_file_14_output_image = imread("/usr/share/mosaicode/extensions/examples/c/opencv/lenna.png", IMREAD_COLOR);
        
        if(!image_file_14_output_image.empty()) 
        	blurred_face_23_input_image = image_file_14_output_image.clone();
        
    if(!blurred_face_23_input_image.empty()){
        blurred_face_23_output_image = blurred_face_23_input_image.clone();
        blurred_face_23_input_integer1 = (blurred_face_23_input_integer1 %2 == 0)? blurred_face_23_input_integer1 + 1 : blurred_face_23_input_integer1;
        blurred_face_23_input_integer2 = (blurred_face_23_input_integer2 %2 == 0)? blurred_face_23_input_integer2 + 1 : blurred_face_23_input_integer2;
        face_cascade_23.load("/opt/opencv/data/haarcascades/haarcascade_frontalface_alt.xml");
        face_cascade_23.detectMultiScale(blurred_face_23_input_image, faces_23, 1.1, 3, 0|CV_HAAR_SCALE_IMAGE, Size(0, 0));
        for(int i = 0; i < faces_23.size(); i++){
            rectangle(blurred_face_23_input_image, faces_23[i], Scalar(0, 0, 0), 1, 8, 0);
            Rect region(faces_23[i].x, faces_23[i].y, faces_23[i].width, faces_23[i].height);
            tmp23 = blurred_face_23_input_image(region);
            GaussianBlur(tmp23, tmp23, Size(0,0), blurred_face_23_input_integer1, blurred_face_23_input_integer2);
            tmp23.copyTo(blurred_face_23_output_image(Rect(faces_23[i].x, faces_23[i].y, faces_23[i].width, faces_23[i].height)));  
        }
    }
        
        if(!blurred_face_23_output_image.empty()) 
        	show_image_4_input_image = blurred_face_23_output_image.clone();

    if(!show_image_4_input_image.empty()){
        imshow("My Image", show_image_4_input_image);
    }

                
    image_file_14_output_image.release();
        
    blurred_face_23_input_image.release();
    blurred_face_23_output_image.release();
    tmp23.release();
        
    show_image_4_input_image.release();

    }

    destroyAllWindows();
    return 0;
}
