Terms and conditions
Preamble:
This Agreement, signed on Jun 10, 2012 [hereinafter: Effective Date] governs the relationship between the Enduser, a private person, (hereinafter: Licensee) and Paul N...
If you think the Android project Operation-Valkyrie listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package org.opencv.core;
//www.java2s.comimport java.util.Arrays;
import java.util.List;
publicclass MatOfRect extends Mat {
// 32SC4
privatestaticfinalint _depth = CvType.CV_32S;
privatestaticfinalint _channels = 4;
public MatOfRect() {
super();
}
protected MatOfRect(long addr) {
super(addr);
if(checkVector(_channels, _depth) < 0 )
thrownew IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
publicstatic MatOfRect fromNativeAddr(long addr) {
returnnew MatOfRect(addr);
}
public MatOfRect(Mat m) {
super(m, Range.all());
if(checkVector(_channels, _depth) < 0 )
thrownew IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public MatOfRect(Rect...a) {
super();
fromArray(a);
}
publicvoid alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
}
publicvoid fromArray(Rect...a) {
if(a==null || a.length==0)
return;
int num = a.length;
alloc(num);
int buff[] = newint[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[] = newint[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;
}
publicvoid fromList(List<Rect> lr) {
Rect ap[] = lr.toArray(new Rect[0]);
fromArray(ap);
}
public List<Rect> toList() {
Rect[] ar = toArray();
return Arrays.asList(ar);
}
}