public Mat onCameraFrame(CvCameraViewFrame inputFrame) { mRgba = inputFrame.rgba(); mGray = inputFrame.gray(); MatOfRect faces = new MatOfRect(); Core.flip(mRgba.t(), mRgba, -1); Core.flip(mGray.t(), mGray, -1); if (mNativeDetector != null) mNativeDetector.detect(mGray, faces); Rect[] facesArray = faces.toArray(); for (int i = 0; i < facesArray.length; i++) Core.rectangle(mRgba, facesArray[i].tl(), facesArray[i].br(), FACE_RECT_COLOR, 2); return mRgba; }
public void fromArray(Rect...a) { if(a==null || a.length==0) return; int num = a.length; alloc(num); int buff[] = new int[num * _channels]; for(int i=0; i<num; i++) { Rect r = a[i]; buff[_channels*i+0] = (int) r.x; buff[_channels*i+1] = (int) r.y; buff[_channels*i+2] = (int) r.width; buff[_channels*i+3] = (int) r.height; } put(0, 0, buff); //TODO: check ret val! }
protected MatOfRect(long addr) { super(addr); if( !empty() && checkVector(_channels, _depth) < 0 ) throw new IllegalArgumentException("Incompatible Mat"); //FIXME: do we need release() here? }
public Rect[] toArray() { int num = (int) total(); Rect[] a = new Rect[num]; if(num == 0) return a; int buff[] = new int[num * _channels]; get(0, 0, buff); //TODO: check ret val! for(int i=0; i<num; i++) a[i] = new Rect(buff[i*_channels], buff[i*_channels+1], buff[i*_channels+2], buff[i*_channels+3]); return a; } public void fromList(List<Rect> lr) {
public List<Rect> toList() { Rect[] ar = toArray(); return Arrays.asList(ar); } }
public static MatOfRect fromNativeAddr(long addr) { return new MatOfRect(addr); }
public MatOfRect(Rect...a) { super(); fromArray(a); }
public Rect[] toArray() { int num = (int) total(); Rect[] a = new Rect[num]; if(num == 0) return a; int buff[] = new int[num * _channels]; get(0, 0, buff); //TODO: check ret val! for(int i=0; i<num; i++) a[i] = new Rect(buff[i*_channels], buff[i*_channels+1], buff[i*_channels+2], buff[i*_channels+3]); return a; } public void fromList(List<Rect> lr) {
public List<Rect> toList() { Rect[] ar = toArray(); return Arrays.asList(ar); } }
public static MatOfRect fromNativeAddr(long addr) { return new MatOfRect(addr); }
public MatOfRect(Rect...a) { super(); fromArray(a); }
protected MatOfRect(long addr) { super(addr); if( !empty() && checkVector(_channels, _depth) < 0 ) throw new IllegalArgumentException("Incompatible Mat"); //FIXME: do we need release() here? }
public void fromArray(Rect...a) { if(a==null || a.length==0) return; int num = a.length; alloc(num); int buff[] = new int[num * _channels]; for(int i=0; i<num; i++) { Rect r = a[i]; buff[_channels*i+0] = (int) r.x; buff[_channels*i+1] = (int) r.y; buff[_channels*i+2] = (int) r.width; buff[_channels*i+3] = (int) r.height; } put(0, 0, buff); //TODO: check ret val! }
public Rect[] toArray() { int num = (int) total(); Rect[] a = new Rect[num]; if(num == 0) return a; int buff[] = new int[num * _channels]; get(0, 0, buff); //TODO: check ret val! for(int i=0; i<num; i++) a[i] = new Rect(buff[i*_channels], buff[i*_channels+1], buff[i*_channels+2], buff[i*_channels+3]); return a; } public void fromList(List<Rect> lr) {
public List<Rect> toList() { Rect[] ar = toArray(); return Arrays.asList(ar); } }
public static MatOfRect fromNativeAddr(long addr) { return new MatOfRect(addr); }
private void detectAndDrawFace(Mat image) { MatOfRect faceDetections = new MatOfRect(); faceDetector.detectMultiScale( image, faceDetections, 1.1, 7,0,new Size(250,40),new Size()); // Draw a bounding box around each face. for (Rect rect : faceDetections.toArray()) { Imgproc.rectangle(image, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height), new Scalar(0, 255, 0)); } } }
public MatOfRect(Rect...a) { super(); fromArray(a); }
protected MatOfRect(long addr) { super(addr); if( !empty() && checkVector(_channels, _depth) < 0 ) throw new IllegalArgumentException("Incompatible Mat"); //FIXME: do we need release() here? }
public void fromArray(Rect...a) { if(a==null || a.length==0) return; int num = a.length; alloc(num); int buff[] = new int[num * _channels]; for(int i=0; i<num; i++) { Rect r = a[i]; buff[_channels*i+0] = (int) r.x; buff[_channels*i+1] = (int) r.y; buff[_channels*i+2] = (int) r.width; buff[_channels*i+3] = (int) r.height; } put(0, 0, buff); //TODO: check ret val! }