How can i remove pimples from image using OpenCV in swift?

asked 2018-07-11 06:03:41 -0500

kk143g gravatar image

updated 2018-07-11 08:14:17 -0500

How to remove pimples from face using openCV in swift ios? I have tried with CIFilters but pimples are still there. I have tried to detect pimples through this code in OPENCV class

  for( size_t i = 0; i< contours.size(); i++ )
    {

        if( contourArea(contours[i]) > 20 & contourArea(contours[i]) < 150 )
        {
            cv::Rect minRect = boundingRect(cv::Mat(contours[i]));
            cv::Mat imgroi(cameraFeed,minRect);

            cvtColor(imgroi,imgroi,cv::COLOR_BGR2HSV);
            cv::Scalar color =mean(imgroi);
            cvtColor(imgroi,imgroi,cv::COLOR_HSV2BGR);

            if(color[0] < 10 & color[1] > 70 & color[2] > 50)
            {
                cv::Point2f center, vtx[4];
                float radius = 0;
                cv::minEnclosingCircle(cv::Mat(contours[i]), center, radius);

                if(radius < 20)
                {
                    cv::rectangle(cameraFeed,minRect,cvScalar(0,255,0));
                    pimplescount++;
                }
            }
        }
    }
edit retag flag offensive close merge delete