Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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

How to remove pimples from face using openCV in swift ios? I have tried with CIFilters but pimples are still there

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

How to remove pimples from face using openCV in swift ios? I have tried with CIFilters but pimples are still therethere. 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++;
                }
            }
        }
    }

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

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++;
                }
            }
        }
    }