- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
基于 Google Vision Face Tracker 的面部追踪器应用程序.默认情况下,Face Tracker 使用后置/后置摄像头,但我想使用前置摄像头检测人脸。
这是google vision提供的CameraSourcePreview的代码:
package com.google.android.gms.samples.vision.face.facetracker.ui.camera;
import android.content.Context;
import android.content.res.Configuration;
import android.util.AttributeSet;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.ViewGroup;
import com.google.android.gms.common.images.Size;
import com.google.android.gms.vision.CameraSource;
import java.io.IOException;
public class CameraSourcePreview extends ViewGroup {
private static final String TAG = "CameraSourcePreview";
private Context mContext;
private SurfaceView mSurfaceView;
private boolean mStartRequested;
private boolean mSurfaceAvailable;
private CameraSource mCameraSource;
private GraphicOverlay mOverlay;
public CameraSourcePreview(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
mStartRequested = false;
mSurfaceAvailable = false;
mSurfaceView = new SurfaceView(context);
mSurfaceView.getHolder().addCallback(new SurfaceCallback());
addView(mSurfaceView);
}
public void start(CameraSource cameraSource) throws IOException {
if (cameraSource == null) {
stop();
}
mCameraSource = cameraSource;
if (mCameraSource != null) {
mStartRequested = true;
startIfReady();
}
}
public void start(CameraSource cameraSource, GraphicOverlay overlay) throws IOException {
mOverlay = overlay;
start(cameraSource);
}
public void stop() {
if (mCameraSource != null) {
mCameraSource.stop();
}
}
public void release() {
if (mCameraSource != null) {
mCameraSource.release();
mCameraSource = null;
}
}
private void startIfReady() throws IOException {
if (mStartRequested && mSurfaceAvailable) {
mCameraSource.start(mSurfaceView.getHolder());
if (mOverlay != null) {
Size size = mCameraSource.getPreviewSize();
int min = Math.min(size.getWidth(), size.getHeight());
int max = Math.max(size.getWidth(), size.getHeight());
if (isPortraitMode()) {
// Swap width and height sizes when in portrait, since it will be rotated by
// 90 degrees
mOverlay.setCameraInfo(min, max, mCameraSource.getCameraFacing());
} else {
mOverlay.setCameraInfo(max, min, mCameraSource.getCameraFacing());
}
mOverlay.clear();
}
mStartRequested = false;
}
}
private class SurfaceCallback implements SurfaceHolder.Callback {
@Override
public void surfaceCreated(SurfaceHolder surface) {
mSurfaceAvailable = true;
try {
startIfReady();
} catch (IOException e) {
Log.e(TAG, "Could not start camera source.", e);
}
}
@Override
public void surfaceDestroyed(SurfaceHolder surface) {
mSurfaceAvailable = false;
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
}
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
int width = 640;
int height = 480;
if (mCameraSource != null) {
Size size = mCameraSource.getPreviewSize();
if (size != null) {
width = size.getWidth();
height = size.getHeight();
}
}
// Swap width and height sizes when in portrait, since it will be rotated 90 degrees
if (isPortraitMode()) {
int tmp = width;
width = height;
height = tmp;
}
final int layoutWidth = right - left;
final int layoutHeight = bottom - top;
// Computes height and width for potentially doing fit width.
int childWidth = layoutWidth;
int childHeight = (int)(((float) layoutWidth / (float) width) * height);
// If height is too tall using fit width, does fit height instead.
if (childHeight > layoutHeight) {
childHeight = layoutHeight;
childWidth = (int)(((float) layoutHeight / (float) height) * width);
}
for (int i = 0; i < getChildCount(); ++i) {
getChildAt(i).layout(0, 0, childWidth, childHeight);
}
try {
startIfReady();
} catch (IOException e) {
Log.e(TAG, "Could not start camera source.", e);
}
}
private boolean isPortraitMode() {
int orientation = mContext.getResources().getConfiguration().orientation;
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
return false;
}
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
return true;
}
Log.d(TAG, "isPortraitMode returning false by default");
return false;
}
}
我用这个方法调用相机源:
private void startCameraSource() {
// check that the device has play services available.
int code = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(
getApplicationContext());
if (code != ConnectionResult.SUCCESS) {
Dialog dlg =
GoogleApiAvailability.getInstance().getErrorDialog(this, code, RC_HANDLE_GMS);
dlg.show();
}
if (mCameraSource != null) {
try {
mPreview.start(mCameraSource, mGraphicOverlay);
} catch (IOException e) {
Log.e(TAG, "Unable to start camera source.", e);
mCameraSource.release();
mCameraSource = null;
}
}
}
与默认手机摄像头应用程序相比,Face Tracker 前置摄像头仍然太暗。
如何在面部跟踪器 google vision 中调亮前置摄像头?与表面 View 有关吗?
<com.google.android.gms.samples.vision.face.facetracker.ui.camera.CameraSourcePreview
android:id="@+id/preview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.00"
android:weightSum="1">
<com.google.android.gms.samples.vision.face.facetracker.ui.camera.GraphicOverlay
android:id="@+id/faceOverlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.79" />
</com.google.android.gms.samples.vision.face.facetracker.ui.camera.CameraSourcePreview>
最佳答案
它与 SurfaceView 完全无关。这是 Camera API 配置错误。您必须在 CameraSource.java 文件中进行一些额外的更改。您可以在 this GitHub repository 上找到它
首先,你需要知道这是一个曝光问题。它是指相机允许在镜头上接收到的光线。您需要知道您的相机是否支持曝光补偿。您将不得不查询 getMinExposureCompensation()和 getMaxExposureCompensation()来自您的 Camera.Parameters 实例。如文档所述,如果两种方法都返回 0,则不支持曝光补偿,您也无能为力。
幸运的是,大部分时间所有手机都支持此功能。现在您可以通过调用 getExposureCompensation() 查看当前相机曝光这将返回默认值(通常为 0,表示不调整曝光)。现在为了防止图像变暗,您只需使用setExposureCompensation() 将新的曝光设置在最小值和最大值之间。并将 Camera.Parameters 应用于您的相机。
最后,您可以使用 setAutoExposureLock() 锁定曝光以避免丢失配置。 , getAutoExposureLock()最重要的是:在设置曝光锁之前,您必须确保 isAutoExposureLockSupported()返回真。
祝你好运!
关于android - 面部跟踪器 CameraSource Android : How to brighten front camera quality?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41766196/
我需要跟踪包含数千个 JAR 和 .CLASS 文件的已编译 Java 应用程序,您知道有什么合适的工具可以附加到 JVM 来跟踪函数调用(无需源代码)吗? 最佳答案 是的。 Jprofiler无需源
我想使用深度学习和计算机视觉技术来检测和统计葡萄园中葡萄藤的数量。我正在使用 YOLOv4 对象检测器并在 darknet 上进行训练框架。我已经能够将 SORT 跟踪器集成到我的应用程序中并且运行良
我有一个分为两部分的问题 (1) 如何在用户不移动时暂停事件跟踪,(2) 这可以节省电池生命周期吗? 更多信息。我正在构建一个事件跟踪器,但用于通常涉及大量暂停的事件 - 例如。步行30分钟,在一个位
我需要能够在一个页面上使用多个 Google Analytics(分析)。我怎样才能用异步代码做到这一点? 让跟踪器的工作方式有点像这样(不确定确切的代码): var tracker2 = _gat.
我正在尝试为我的 Android 应用设置 Google Analytics v2。 现在,我正在尝试通过为我的 Activity 和 fragment 设置跟踪器来跟踪不同的屏幕。我有两个所有东西都
您知道有哪些易于使用、简洁的 Python 或 Perl API 可以与 BitTorrent Tracker 进行交互吗?例如,我获取一个 torrent 文件,枚举文件中的所有跟踪器,并向跟踪器询
我一直在尝试为 SEO 编写自己的关键字位置排名扫描器。我找到了一个 PHP 类,它看起来很有用,但我不知道如何让它工作。 我对在 PHP 中使用类/函数还很陌生。 这是我找到的代码: http://
我正在使用 KCF 跟踪算法,我的问题是当目标退出窗口时,跟踪器不会重置并错误地在窗口边缘显示它的矩形。在理想状态下,跟踪器应该在失去目标时删除矩形。 这些是我的代码: int main(int ar
我正在开发一项服务,用于跟踪互联网上的节点。该服务将按日期时间对节点列表进行排序,并且数据库不需要在崩溃中幸存下来(http://wiki.postgresql.org/wiki/What%27s_n
我有一个如下所示的类,当我通过命令行运行它时,我想查看进度状态。类似的东西, 10% completed... 30% completed... 100% completed...Job done!
我已经按照入门指南进行了一些扩展,以了解之前的 Angular 2 版本。我已经更新了我的修订版并相应地更改了所有内容。当我运行 Web 服务器时,我现在收到 traceur 错误 404... 这是
我正在开发一个使用 GPS/GPRS/GSM 的车辆跟踪系统。我目前使用的追踪设备是 GV100,这是一款来自 Quectel ([www.quectel.com][1]) 的 GPS/GPRS/GS
我将 angular2 从 RC2 迁移到 RC4,现在收到以下错误: localhost/:36 Error: Error: XHR error (404 Not Found) loading ht
我目前正在尝试在 nodeJS 中实现一个最小的 torrent 客户端。 我正在阅读此规范:https://wiki.theory.org/index.php/BitTorrentSpecifica
我正在使用 OpenCV 跟踪器在视频中执行人脸跟踪,每隔几帧使用人脸检测器。如果人脸检测器检测到人脸,我想用“检测到的”边界框更新跟踪器。我看到在 C++ 实现中有一个输入 Rect 的选项,但由于
我刚刚安装了 Mantis 错误跟踪器以与 Eclipse IDE 一起使用,并且已经开始发现它的优点。真的很棒。 由于 Eclipse 通过 PHP soap API 与 Mantis 通信,我想知
使用 Google Analytics 的 Javascript 跟踪器,如果有人访问 IP #1 的网站,1 小时后(同一天)使用另一个 IP #2(但在同一浏览器中)访问网站,是否算作 1 或2
很抱歉打扰您,但我已经为此苦苦挣扎了近两周,并进行了很多研究,但没有找到任何解决方案: 我正在尝试运行这个 git 项目 open gps tracker ,在本地它运行完美,但是当我将它部署到开放
我有一个 asp net 项目,我必须在登录后向 Mantis 跟踪器添加一些问题。最好的方法是什么? JS 还是 C#?我找到了几个库(例如 Mantis-JS),但我发现没有文档,我不明白我应该做
我发送了一个抓取数据包,播种器、下载器和盗取器总是返回 0。 这是我的初始连接和抓取代码。 public void scrape() { for (final String infoh
我是一名优秀的程序员,十分优秀!