本文整理汇总了Java中com.tzutalin.dlib.VisionDetRet类的典型用法代码示例。如果您正苦于以下问题:Java VisionDetRet类的具体用法?Java VisionDetRet怎么用?Java VisionDetRet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VisionDetRet类属于com.tzutalin.dlib包,在下文中一共展示了VisionDetRet类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDetBitmapFace
import com.tzutalin.dlib.VisionDetRet; //导入依赖的package包/类
@Test
public void testDetBitmapFace() {
FaceDet faceDet = new FaceDet(Constants.getFaceShapeModelPath());
Bitmap bitmap = BitmapFactory.decodeFile("/sdcard/test.jpg");
assertThat(bitmap, notNullValue());
List<VisionDetRet> results = faceDet.detect(bitmap);
for (final VisionDetRet ret : results) {
String label = ret.getLabel();
int rectLeft = ret.getLeft();
int rectTop = ret.getTop();
int rectRight = ret.getRight();
int rectBottom = ret.getBottom();
assertThat(label, is("face"));
Assert.assertTrue(rectLeft > 0);
}
faceDet.release();
}
示例2: testDetFace
import com.tzutalin.dlib.VisionDetRet; //导入依赖的package包/类
@Test
public void testDetFace() {
Bitmap bitmap = BitmapFactory.decodeFile("/sdcard/test.jpg");
assertThat(bitmap, notNullValue());
FaceDet faceDet = new FaceDet(Constants.getFaceShapeModelPath());
List<VisionDetRet> results = faceDet.detect("/sdcard/test.jpg");
for (final VisionDetRet ret : results) {
String label = ret.getLabel();
int rectLeft = ret.getLeft();
int rectTop = ret.getTop();
int rectRight = ret.getRight();
int rectBottom = ret.getBottom();
assertThat(label, is("face"));
Assert.assertTrue(rectLeft > 0);
}
faceDet.release();
}
示例3: testDetBitmapFaceLandmarkDect
import com.tzutalin.dlib.VisionDetRet; //导入依赖的package包/类
@Test
public void testDetBitmapFaceLandmarkDect() {
Bitmap bitmap = BitmapFactory.decodeFile("/sdcard/test.jpg");
assertThat(bitmap, notNullValue());
FaceDet faceDet = new FaceDet(Constants.getFaceShapeModelPath());
List<VisionDetRet> results = faceDet.detect(bitmap);
for (final VisionDetRet ret : results) {
String label = ret.getLabel();
int rectLeft = ret.getLeft();
int rectTop = ret.getTop();
int rectRight = ret.getRight();
int rectBottom = ret.getBottom();
ArrayList<Point> landmarks = ret.getFaceLandmarks();
assertThat(label, is("face"));
Assert.assertTrue(landmarks.size() > 0);
Assert.assertTrue(rectLeft > 0);
}
faceDet.release();
}
示例4: testDetFaceLandmark
import com.tzutalin.dlib.VisionDetRet; //导入依赖的package包/类
@Test
public void testDetFaceLandmark() {
FaceDet faceDet = new FaceDet(Constants.getFaceShapeModelPath());
List<VisionDetRet> results = faceDet.detect("/sdcard/test.jpg");
for (final VisionDetRet ret : results) {
String label = ret.getLabel();
int rectLeft = ret.getLeft();
int rectTop = ret.getTop();
int rectRight = ret.getRight();
int rectBottom = ret.getBottom();
ArrayList<Point> landmarks = ret.getFaceLandmarks();
assertThat(label, is("face"));
Assert.assertTrue(landmarks.size() > 0);
Assert.assertTrue(rectLeft > 0);
}
faceDet.release();
}
示例5: testFacialLandmark
import com.tzutalin.dlib.VisionDetRet; //导入依赖的package包/类
@Test
public void testFacialLandmark() {
PedestrianDet peopleDet = new PedestrianDet();
List<VisionDetRet> results = peopleDet.detect("/sdcard/test.bmp");
for (final VisionDetRet ret : results) {
String label = ret.getLabel();
int rectLeft = ret.getLeft();
int rectTop= ret.getTop();
int rectRight = ret.getRight();
int rectBottom = ret.getBottom();
}
}
示例6: drawRect
import com.tzutalin.dlib.VisionDetRet; //导入依赖的package包/类
@DebugLog
protected BitmapDrawable drawRect(String path, List<VisionDetRet> results, int color) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 1;
Bitmap bm = BitmapFactory.decodeFile(path, options);
android.graphics.Bitmap.Config bitmapConfig = bm.getConfig();
// set default bitmap config if none
if (bitmapConfig == null) {
bitmapConfig = android.graphics.Bitmap.Config.ARGB_8888;
}
// resource bitmaps are imutable,
// so we need to convert it to mutable one
bm = bm.copy(bitmapConfig, true);
int width = bm.getWidth();
int height = bm.getHeight();
// By ratio scale
float aspectRatio = bm.getWidth() / (float) bm.getHeight();
final int MAX_SIZE = 512;
int newWidth = MAX_SIZE;
int newHeight = MAX_SIZE;
float resizeRatio = 1;
newHeight = Math.round(newWidth / aspectRatio);
if (bm.getWidth() > MAX_SIZE && bm.getHeight() > MAX_SIZE) {
Timber.tag(TAG).d("Resize Bitmap");
bm = getResizedBitmap(bm, newWidth, newHeight);
resizeRatio = (float) bm.getWidth() / (float) width;
Timber.tag(TAG).d("resizeRatio " + resizeRatio);
}
// Create canvas to draw
Canvas canvas = new Canvas(bm);
Paint paint = new Paint();
paint.setColor(color);
paint.setStrokeWidth(2);
paint.setStyle(Paint.Style.STROKE);
// Loop result list
for (VisionDetRet ret : results) {
Rect bounds = new Rect();
bounds.left = (int) (ret.getLeft() * resizeRatio);
bounds.top = (int) (ret.getTop() * resizeRatio);
bounds.right = (int) (ret.getRight() * resizeRatio);
bounds.bottom = (int) (ret.getBottom() * resizeRatio);
canvas.drawRect(bounds, paint);
// Get landmark
ArrayList<Point> landmarks = ret.getFaceLandmarks();
for (Point point : landmarks) {
int pointX = (int) (point.x * resizeRatio);
int pointY = (int) (point.y * resizeRatio);
canvas.drawCircle(pointX, pointY, 2, paint);
}
}
return new BitmapDrawable(getResources(), bm);
}