Ask Your Question

orochi's profile - activity

2020-07-06 14:57:21 -0600 received badge  Popular Question (source)
2018-06-12 18:50:57 -0600 received badge  Famous Question (source)
2017-12-14 00:56:32 -0600 received badge  Famous Question (source)
2017-11-24 05:02:40 -0600 received badge  Notable Question (source)
2017-02-12 07:58:13 -0600 received badge  Popular Question (source)
2016-01-28 08:40:40 -0600 received badge  Notable Question (source)
2015-09-11 08:03:35 -0600 received badge  Famous Question (source)
2015-04-07 09:48:13 -0600 commented question Change background of ellipse mask into transparent

Hi @Haris, thanks for the comment, i've try to change the order of rgba.add , but it doesnt do anything, can you point me to article or something that can give some idea to solve this problem. i've try to search it, but cant find something relevant with this problem yet.

2015-04-07 02:31:35 -0600 commented question Change background of ellipse mask into transparent

hi @Haris, i've manage to make the background transparent using your solution. but there is another problem, color of the main image is look weird, i update my question for reference.

2015-04-01 08:24:04 -0600 commented question Change background of ellipse mask into transparent

woah thanks a lot!!! its look like helpful, i'll try to do like the answer suggested

2015-04-01 02:41:28 -0600 asked a question Change background of ellipse mask into transparent

Hi, based on answer from this question, i try to make an ellipse mask from my real time face detection and then change the background of the ellipse into transparent.

Using an answer suggested in this question i manage to change the background into transparent, but color of the main image looks weird. here the result: image description and this is the snipped of my code

public boolean userFace(Mat matFace)
{           

    // init new matrices
    Mat dst = new Mat(matFace.rows(), matFace.cols(), CvType.CV_8UC4);
    Mat tmp = new Mat(matFace.rows(), matFace.cols(), CvType.CV_8UC4);
    Mat alpha = new Mat(matFace.rows(), matFace.cols(), CvType.CV_8UC4);

    // convert image to grayscale
    Imgproc.cvtColor(matFace, tmp, Imgproc.COLOR_BGR2GRAY);

    // threshold the image to create alpha channel with complete transparency in black background region and zero transparency in foreground object region.
    Imgproc.threshold(tmp, alpha, 100, 255, Imgproc.THRESH_BINARY);

    // split the original image into three single channel.
    List<Mat> rgb = new ArrayList<Mat>(3);
    Core.split(matFace, rgb);

    // Create the final result by merging three single channel and alpha(BGRA order)
    List<Mat> rgba = new ArrayList<Mat>(4);
    rgba.add(rgb.get(0));
    rgba.add(rgb.get(1));
    rgba.add(rgb.get(2));
    rgba.add(alpha);
    Core.merge(rgba, dst);

    int width = dst.width(), height = dst.height(), channels = dst.channels() ;  
    byte[] sourcePixels = new byte[width * height * channels];  
    dst.get(0, 0, sourcePixels);  
    // create new image and get reference to backing data  
    faceimage = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);  

    final byte[] targetPixels = ((DataBufferByte) faceimage.getRaster().getDataBuffer()).getData();  
    System.arraycopy(sourcePixels, 0, targetPixels, 0, sourcePixels.length);

    return true;
}

Please, any tutorial, article or something to point me into the solution, i really appreciate it

Btw, i'm using java and opencv 2.4.9

2015-01-18 17:37:44 -0600 commented answer Face Detection through a webcam in java

@moods hi, i never done iris recognition

2015-01-13 02:36:52 -0600 commented answer Face Detection through a webcam in java

@moods hi, i think the first you should do is convert captured face from mat into bufferedimage and then draw it into webcam frame using paint component.

2015-01-07 14:02:30 -0600 asked a question Occlusion in Face Detection and Augmented Reality

Hi guys, I'm doing an augmented reality project based on face detection using Haarcascade from OpenCV and Java. The application will augmented an image onto detected face. So far i manage to detect the face and then apply an image to detected face (at the moment i'm using hijab image). But, the result is not look real enough. I mean, its just like an image with transparent area in the middle being put on top of detected face.

Here is the result from my AR application: image description

and the desired result is (*edited using photoshop) image description

In first image, the chins being covered by hijab image meanwhile the second image is not covered.

How do i handle this occlusion, so when i'm applying a hijab image to detected face, chins is not covered by augmented image. I already try to adjust height of the hijab, and then there will be a little gap between chins and the hijab image.

Any suggestion or what technique i should use to solve the problem?

2015-01-07 12:33:48 -0600 commented answer Face Detection through a webcam in java

Hi @moods, i'm not sure why you get an error, because when i run the code, everything working fine, no error. Try to put Thread.sleep(1000); after VideoCapture(0). and try to copy the files haarcascade_frontalface_alt.xml and haarcascade_eye_tree_eyeglasses.xml in your current directory

2015-01-07 03:52:55 -0600 commented answer Face Detection through a webcam in java

@moods take a look at this question http://answers.opencv.org/question/12... , i post the code there

2015-01-07 03:50:47 -0600 received badge  Enthusiast
2014-12-29 09:14:01 -0600 commented question Crop Face Region from Detected Face

Thanks @Guanta , i'll take a look something similar with ASM but written in java. But if by any chance you found out something else, pls share it. Thanks again @Guanta, really appreciate it

2014-12-29 08:59:37 -0600 commented question Crop Face Region from Detected Face

hi @Guanta , thanks for the comment. What you mean by i need to fit a face model to get the facial parts?

2014-12-29 03:51:16 -0600 commented question hello everybody, am new to opencv. can anybody please explain me about the line const cv::Vec3b rgb = centers_u8c3.ptr<Vec3b>(*label_first)[4];

a little suggestion, next time you post a question, pls dont simply copy and paste your code. narrow down your problem, write a little description about your problem and what you've done so far. it will help other people to address your problem and help you to solve it.

2014-12-29 03:51:16 -0600 asked a question Crop Face Region from Detected Face

Hello,

I'm currently developing an application for face detection and augmented reality using OpenCV and Java. I need to crop out the face region from detected face. I have done detecting the face using haarcascade.

My problem is, when i cropping the face using submat and assigning the region (Rect ) that i get using haarcascade, it didnt give me the desired result. Using submat i get rectangle area around the face (including some of the background, hair, ears) meanwhile i only want face region (including forehead and chin, without ears and head).

I've tried using suggestion from here http://answers.opencv.org/question/26... and here http://answers.opencv.org/question/93...

but i still didnt get the desired result.

Please suggest me how to get exact face region, any article or tutorial.

Thanks

2014-12-29 00:16:29 -0600 received badge  Critic (source)
2014-12-09 13:52:24 -0600 marked best answer augmented reality using java and opencv 2.4.5

hi guys, i want to develop a Marker-less Augmented Reality application, it is a desktop application, not mobile. the application will detect my face through a webcam and then put a 2d mask over it. i want to using opencv and java language but i've some problem to find tutorials on the topic, which steps to follow, possible algorithms. is any of you know good tutorial that i can use as reference to develop this application?

2014-12-09 00:41:48 -0600 asked a question occlusion in face detection and Augmented reality

Hi guys, I've been working on face detection and augmented reality project. So far i manage to detect the face and then apply an image to detected face (at the moment i'm using hijab image). But, the result is not look real enough. I mean, its just like a png image put on top of detected face.

Here is the result from my AR application image description

and result that i expected looks like this (*edited using photoshop)image description

In first image, my chins being covered by hijab image meanwhile the second image, my chins is not covered.

So my question is, how do i handle this occlusion, so when i'm applying a hijab image to detected face, chins is not covered by augmented image. I have try to adjust height of the hijab, but then there will be a little gap between chins and the hijab image.

Any suggestion or what technique i should use to solve the problem?

2014-12-08 19:05:13 -0600 received badge  Notable Question (source)
2014-11-26 21:34:03 -0600 received badge  Popular Question (source)
2014-11-02 06:37:37 -0600 received badge  Famous Question (source)
2014-07-18 12:19:20 -0600 received badge  Notable Question (source)
2014-05-22 03:55:01 -0600 marked best answer Difference between CvMat, cvMat, cv::Mat, and Mat

Hi everyone,

i am quite new into opencv, i will go straight forward, just like title of my question, what is the difference between CvMat, cvMat, cv::Mat, and Mat. i found out that cv::Mat is c++ version of cvMat, but then, is CvMat is same with Mat? and is cvMat is a constructor of CvMat?

The reason i am asking this because i want to write Head Pose Estimation sample using Java. In that sample, inside PAW.cpp i found code like this

Mat warp = cv::Mat(nTriangles, 6, CV_64FC1);

which based on my knowledge, if i turn this code into Java it will become like this

Mat warp = new Mat(nTriangles, 6, CvType.CV_64FC1);

but then when i scroll down PAW.cpp file, i found

//calc scrLandmarks convex hull
    CvPoint* pointsHull = (CvPoint*)malloc( nLandmarks * sizeof(pointsHull[0]));
    int* hull = (int*)malloc( nLandmarks * sizeof(hull[0]));
    CvMat pointMat = cvMat( 1, nLandmarks, CV_32SC2, pointsHull );
    CvMat hullMat = cvMat( 1, nLandmarks, CV_32SC1, hull );

my question is, why the author sometime use Mat and cv::Mat and then sometime use CvMat and cvMat, is there any particular reason?

and if i convert the above code into Java, it will become like this

Point[] pointsHull = new Point[nLandmarks];
int[] hull = new int[nLandmarks];
Mat pointMat = new Mat(1, nLandmarks, CvType.CV_32SC2, pointsHull);
Mat hullMat = new Mat(1, nLandmarks, CvType.CV_32SC1, hull);

but this code will generate an error because in opencv 2.4.5 Java api, i cannot found Mat constructor with argument (int, int, int, Point[]) or (int, int, int, int[]). is the constructor deprecated in opencv 2.4.5 or am i doing it wrongly? i am not a java expert and only has a little knowledge about c++. any hint or suggestion about how to do it correctly?

please excuse my English :D

2014-05-20 00:56:02 -0600 marked best answer real time face tracking java

Hi guys, I'm very vey new to opencv. i'm trying to make a Java program that can detect my face through a webcam. i don't know which library i should import and i don't know how to make it able to detect my webcam. Based on this tutorial i try to write my java code for detecting face through a webcam, but i got so many errors, can someone tell me why the error occur? I'm new in opencv and java.

  import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.MatOfRect;
import org.opencv.core.Point;
import org.opencv.core.Rect;
import org.opencv.core.Scalar;
import org.opencv.core.Size;
import org.opencv.highgui.Highgui;
import org.opencv.highgui.VideoCapture;
import org.opencv.imgproc.Imgproc;
import org.opencv.objdetect.CascadeClassifier;

public class CamCapture {

    /**
     * @param args
     */ 

    public static void main(String[] args) {

        //load opencv native library
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

        String face_cascade_name = "haarcascade_frontalface_alt.xml";
        String eyes_cascade_name = "haarcascade_eye_tree_eyeglasses.xml";
        CascadeClassifier face_cascade = new CascadeClassifier();
        CascadeClassifier eyes_cascade = new CascadeClassifier();
        String window_name = "Capture - Face detection.jpg";

        System.out.println("capture through camera "+Core.VERSION);


        //load the face xml cascade
        if(!face_cascade.load(face_cascade_name))
        {
            System.out.println("Error loading face cascade");
        }
        else
        {
            System.out.println("Success loading face cascade");
        }

        //load the eyes xml cascade
        if(!eyes_cascade.load(eyes_cascade_name))
        {
            System.out.println("Error loading eyes cascade");
        }
        else
        {
            System.out.println("Success loading eyes cascade");
        }

        //detect default camera
        VideoCapture capture = new VideoCapture(0);

        if(!capture.isOpened())
        {
            System.out.println("Did not connected to camera.");
        }
        else
        {
            System.out.println("Conected to camera: "+capture.toString());
        }

        //create new Mat image
        Mat frame = new Mat();
        capture.retrieve(frame);

        Mat frame_gray = new Mat();
        Imgproc.cvtColor(frame, frame_gray, Imgproc.COLOR_BGRA2GRAY);
        Imgproc.equalizeHist(frame_gray, frame_gray);


        MatOfRect faces = new MatOfRect();

        face_cascade.detectMultiScale(frame_gray, faces, 1.1, 2, 0, new Size(30,30), new Size() );


        Rect[] facesArray = faces.toArray();

        for(int i=0; i<facesArray.length; i++)
        {
            Point center = new Point(facesArray[i].x + facesArray[i].width * 0.5, facesArray[i].y + facesArray[i].height * 0.5);
             Core.ellipse(frame, center, new Size(facesArray[i].width * 0.5, facesArray[i].height * 0.5), 0, 0, 360, new Scalar(255, 0, 255), 4, 8, 0);

             Mat faceROI = frame_gray.submat(facesArray[i]);
             MatOfRect eyes = new MatOfRect();

             //-- In each face, detect eyes
             eyes_cascade.detectMultiScale(faceROI, eyes, 1.1, 2, 0,new Size(30,30), new Size());            

             Rect[] eyesArray = eyes.toArray();

             for (int j = 0; j < eyesArray.length; j++)
             {
                Point center1 = new Point(facesArray[i].x + eyesArray[i].x + eyesArray[i].width * 0.5, facesArray[i].y + eyesArray[i].y + eyesArray[i].height * 0.5);
                int radius = (int) Math.round((eyesArray[i].width + eyesArray[i].height) * 0.25);
                Core.circle(frame, center1, radius, new Scalar(255, 0, 0), 4, 8, 0);
             }
        }

        Highgui.imwrite(window_name, frame);
        capture.release();




    }

}
2014-04-22 23:00:27 -0600 received badge  Popular Question (source)
2014-03-10 03:58:21 -0600 commented question Drawcontour on Webcam stream

Hi @berak is this correct?

      List&lt;MatOfPoint&gt; contours = new ArrayList&lt;MatOfPoint&gt;(); 
     Imgproc.threshold(mGrey, mTreshold, 0, 255, Imgproc.THRESH_BINARY);

     for(Rect rect:faces.toArray())  
     {  
          Point center= new Point(rect.x + rect.width*0.5, rect.y + rect.height*0.5 );  
          Core.ellipse( mRgba, center, new Size( rect.width*0.5, rect.height*0.5), 0, 0, 360, new Scalar( 255, 0, 255 ), 4, 8, 0 ); 
        //find the contours
          Imgproc.findContours(mTreshold, contours, new Mat(), Imgproc.RETR_LIST,Imgproc.CHAIN_APPROX_SIMPLE);
          //draw the contours
          Imgproc.drawContours(mRgba, contours, 1, new Scalar(0,0,255));
     }  
     return mRgba;

but still no contour

2014-03-05 02:51:55 -0600 asked a question Drawcontour on Webcam stream

Hi all, I need some help. I create face detection through a webcam. So far i manage to draw an ellipse circle on detected face, realtime. then i want to draw contour of the face, i use findCountours and drawContours, no errors in my code, but it wont draw the contours.

here snippet of my code

 import java.util.ArrayList;
import java.util.List;

import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.MatOfPoint;
import org.opencv.core.MatOfRect;
import org.opencv.core.Point;
import org.opencv.core.Rect;
import org.opencv.core.Scalar;
import org.opencv.core.Size;
import org.opencv.imgproc.Imgproc;
import org.opencv.objdetect.CascadeClassifier;

class FaceDetector {  
    private CascadeClassifier face_cascade;  
    // Create a constructor method  
    public FaceDetector(){  
         face_cascade=new CascadeClassifier("./cascades/haarcascade_frontalface_alt.xml");  
         if(face_cascade.empty())  
         {  
              System.out.println("Error loading Cascade Classifier");  
               return;  
         }  
         else  
         {  
                    System.out.println("Face classifier loaded up");  
         }  
    }  
    public Mat detect(Mat inputframe){  
         Mat mRgba=new Mat();  
         Mat mGrey=new Mat(); 
         MatOfRect faces = new MatOfRect();  
         inputframe.copyTo(mRgba);  
         inputframe.copyTo(mGrey);  
         Imgproc.cvtColor( mRgba, mGrey, Imgproc.COLOR_BGR2GRAY);  
         Imgproc.equalizeHist( mGrey, mGrey );  
         face_cascade.detectMultiScale(mGrey, faces);  
         System.out.println(String.format("Detected %s faces", faces.toArray().length));  

         List<MatOfPoint> contours = new ArrayList<MatOfPoint>(); 

         //find the contours
         Imgproc.findContours(mGrey, contours, new Mat(), Imgproc.RETR_LIST,Imgproc.CHAIN_APPROX_SIMPLE);


         for(Rect rect:faces.toArray())  
         {  
              Point center= new Point(rect.x + rect.width*0.5, rect.y + rect.height*0.5 );  
              Core.ellipse( mRgba, center, new Size( rect.width*0.5, rect.height*0.5), 0, 0, 360, new Scalar( 255, 0, 255 ), 4, 8, 0 ); 

              //draw the contours
              Imgproc.drawContours(mRgba, contours, 1, new Scalar(0,0,255));
         }  
         return mRgba;  
    }  
}

am i doing it correctly?

2014-02-18 22:59:01 -0600 received badge  Notable Question (source)
2014-02-18 22:57:27 -0600 received badge  Popular Question (source)
2013-11-20 22:42:13 -0600 received badge  Popular Question (source)
2013-06-18 09:30:10 -0600 commented answer Convert c++ code to java code

hi @comwizz2, do you know what equal method of CvSeqReader, cvStartReadSeq, and CvQuadEdge2D in opencv java?

2013-06-13 09:01:00 -0600 commented answer How to edit/reading pixels from Mat(Vec3b) using Java

hey @gargsl, thank you for the answer, i really appreciate it. actually i have a lot of question regarding opencv and java. if you have any good documentation or tutorial or example about developing an app using opencv and java, can you share it?