{"action":"created","issue":{"url":"https://api.github.com/repos/bytedeco/javacv/issues/152","labels_url":"https://api.github.com/repos/bytedeco/javacv/issues/152/labels{/name}","comments_url":"https://api.github.com/repos/bytedeco/javacv/issues/152/comments","events_url":"https://api.github.com/repos/bytedeco/javacv/issues/152/events","html_url":"https://github.com/bytedeco/javacv/issues/152","id":78068335,"number":152,"title":"How to grab the RGB frame instead the gray one?","user":{"login":"deddygnwn14","id":12512366,"avatar_url":"https://avatars.githubusercontent.com/u/12512366?v=3","gravatar_id":"","url":"https://api.github.com/users/deddygnwn14","html_url":"https://github.com/deddygnwn14","followers_url":"https://api.github.com/users/deddygnwn14/followers","following_url":"https://api.github.com/users/deddygnwn14/following{/other_user}","gists_url":"https://api.github.com/users/deddygnwn14/gists{/gist_id}","starred_url":"https://api.github.com/users/deddygnwn14/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deddygnwn14/subscriptions","organizations_url":"https://api.github.com/users/deddygnwn14/orgs","repos_url":"https://api.github.com/users/deddygnwn14/repos","events_url":"https://api.github.com/users/deddygnwn14/events{/privacy}","received_events_url":"https://api.github.com/users/deddygnwn14/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/bytedeco/javacv/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-05-19T12:30:38Z","updated_at":"2015-05-25T11:53:21Z","closed_at":"2015-05-23T23:01:05Z","body":"In FacePreview.java https://code.google.com/p/javacv/source/browse/samples/FacePreview.java\r\nI don't understand at this part : \r\nprotected void processImage(byte[] data, int width, int height) {\r\n        // First, downsample our image and convert it into a grayscale IplImage\r\n        int f = SUBSAMPLING_FACTOR;\r\n        if (grayImage == null || grayImage.width() != width/f || grayImage.height() != height/f) {\r\n            grayImage = IplImage.create(width/f, height/f, IPL_DEPTH_8U, 1);\r\n        }\r\n        int imageWidth  = grayImage.width();\r\n        int imageHeight = grayImage.height();\r\n        int dataStride = f*width;\r\n        int imageStride = grayImage.widthStep();\r\n        ByteBuffer imageBuffer = grayImage.getByteBuffer();\r\n        for (int y = 0; y < imageHeight; y++) {\r\n            int dataLine = y*dataStride;\r\n            int imageLine = y*imageStride;\r\n            for (int x = 0; x < imageWidth; x++) {\r\n                imageBuffer.put(imageLine + x, data[dataLine + f*x]);\r\n            }\r\n        }\r\n\r\n        cvClearMemStorage(storage);\r\n        faces = cvHaarDetectObjects(grayImage, classifier, storage, 1.1, 3, CV_HAAR_DO_CANNY_PRUNING);\r\n        postInvalidate();\r\n    }\r\n\r\n\r\nAt this part grayImage = IplImage.create(width/f, height/f, IPL_DEPTH_8U, 1);\r\ncan I create it like this rgbImage = IplImage.create(width/f, height/f, IPL_DEPTH_32F, 3); to get an rgb image and later convert it to gray by doing cvCvtColor(rgbImage, grayImage, cv_bgr2gray); and then proceed with haar like this? faces = cvHaarDetectObjects(grayImage, classifier, storage, 1.1, 3, CV_HAAR_DO_CANNY_PRUNING);\r\n        postInvalidate();\r\n    }\r\n\r\nBecause I want to crop the rgbImage with ROI that created by the result of cvHaarDetectObjects using this rect: CvRect r = new CvRect(cvGetSeqElem(faces, i));\r\n                int x = r.x(), y = r.y(), w = r.width(), h = r.height();\r\n\r\nI tried it but it failed and nothing detected.\r\n\r\nI'm sorry if I'm asking too much, but thank you for responding.\r\n"},"comment":{"url":"https://api.github.com/repos/bytedeco/javacv/issues/comments/105218041","html_url":"https://github.com/bytedeco/javacv/issues/152#issuecomment-105218041","issue_url":"https://api.github.com/repos/bytedeco/javacv/issues/152","id":105218041,"user":{"login":"saudet","id":3328023,"avatar_url":"https://avatars.githubusercontent.com/u/3328023?v=3","gravatar_id":"","url":"https://api.github.com/users/saudet","html_url":"https://github.com/saudet","followers_url":"https://api.github.com/users/saudet/followers","following_url":"https://api.github.com/users/saudet/following{/other_user}","gists_url":"https://api.github.com/users/saudet/gists{/gist_id}","starred_url":"https://api.github.com/users/saudet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saudet/subscriptions","organizations_url":"https://api.github.com/users/saudet/orgs","repos_url":"https://api.github.com/users/saudet/repos","events_url":"https://api.github.com/users/saudet/events{/privacy}","received_events_url":"https://api.github.com/users/saudet/received_events","type":"User","site_admin":false},"created_at":"2015-05-25T11:53:21Z","updated_at":"2015-05-25T11:53:21Z","body":"Call `AndroidFrameConverter.convert()` this way: `convert(data, width, height)`."}}