这里是我的问题,我目前无法填充3个表面中的一个仍然从Camera2API捕获的图像后调用捕获。我使用Google Camera2入门(需要链接)来设置样板,所以这段代码的大部分看起来可能很熟悉。
Camera2捕获声明:
每个请求将生成一个CaptureResult,并为一个或多个目标曲面生成新的框架,使用CaptureRequest构建器的addTarget(Surface)方法设置。目标曲面(用addTarget(Surface)设置)必须是创建此捕获会话时提供的曲面的子集。
// in order to use a surface they must be registered when creating the session
List<Surface> surfaces = new ArrayList<>(previewSurfaces); //size + 1
surfaces.addAll(displaySurfaces); // size + 1
surfaces.add(mImageReader.getSurface()); //size + 1
try {
mCameraDevice.createCaptureSession(surfaces, mCaptureSessionCallback , null);
...
// Add the display surfaces along with the internal image reader
captureBuilder.addTarget(mImageReader.getSurface());
for(Surface surface : this.displaySurfaces) {
captureBuilder.addTarget(surface); //theres only one
}
CaptureRequest captureRequest = captureBuilder.build();
mCaptureSession.capture(captureRequest, captureCallback, mBackgroundHandler);
下面是表面是如何生成的;
private SurfaceView getPreviewView(Context context) throws CameraAccessException {
// TODO set z overlay?
Size previewSize = mCameraController.determineLargestSize();
Log.d(LOG_TAG, "Setting preview dimensions to: \n" +
"width: " + Integer.toString(previewSize.getWidth()) + "\n" +
"height " + Integer.toString(previewSize.getHeight()));
SurfaceView view = new SurfaceView(context);
view.getHolder().addCallback(mPreviewViewCallback);
view.getHolder().setFixedSize(previewSize.getWidth(),previewSize.getHeight());
view.setOnTouchListener(mZoomFocusListener);
return view;
}
private SurfaceView getDisplayTile(Context context) throws CameraAccessException {
SurfaceView previewTile = new SurfaceView(context);
Size smallest = mCameraController.determineSmallestSize();
int width = smallest.getWidth();
int height = smallest.getHeight();
Log.d(LOG_TAG, "Setting display tile dimensions to: \n" +
"width: " + Integer.toString(smallest.getWidth()) + "\n" +
"height " + Integer.toString(smallest.getHeight()));
previewTile.getHolder().addCallback(mDisplayCallback);
previewTile.getHolder().setFixedSize(width,height);
previewTile.setZOrderMediaOverlay(true);
previewTile.getHolder().setFormat(PixelFormat.TRANSLUCENT);
previewTile.setBackgroundColor(Color.BLUE);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(width,height);
params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
params.addRule(RelativeLayout.ALIGN_PARENT_END);
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
params.setMargins(7,7,7,7);
previewTile.setLayoutParams(params);
return previewTile;
}
这就是我如何把一切都聚集在一起
private void initViews(Context context) throws CameraAccessException {
mFrameLayout = new FrameLayout(context);
// Add the view for the camera preview
FrameLayout.LayoutParams surfaceParams = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT);
mPreviewView = this.getPreviewView(context);
mFrameLayout.addView(mPreviewView,surfaceParams);
// Add the preview tile to the layout
FrameLayout.LayoutParams displayParams = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.WRAP_CONTENT,
FrameLayout.LayoutParams.WRAP_CONTENT);
displayParams.gravity = Gravity.BOTTOM | Gravity.RIGHT;
RelativeLayout layout = new RelativeLayout(context);
mCapturedTile = this.getDisplayTile(context);
layout.addView(mCapturedTile);
mFrameLayout.addView(layout, displayParams);
}
我还附上了Logcat,让你知道发生了什么
12-19 16:00:33.185 29863-29863/ngc.com.camera2app I/CameraController: This device has 2 available cameras
12-19 16:00:33.202 29863-29863/ngc.com.camera2app D/CameraController: Retrieveing current crop region
12-19 16:00:33.206 29863-29863/ngc.com.camera2app D/CameraView: Setting preview dimensions to:
width: 3264
height 2448
12-19 16:00:33.208 29863-29863/ngc.com.camera2app D/CameraView: Setting display tile dimensions to:
width: 176
height 144
12-19 16:00:33.948 29863-29863/ngc.com.camera2app D/CameraView: Surface created
12-19 16:00:33.949 29863-29863/ngc.com.camera2app D/CameraView: preview surface changed dimensions are
12-19 16:00:33.950 29863-29863/ngc.com.camera2app D/CameraView: width : 3264 | height : 2448
12-19 16:00:33.964 29863-29863/ngc.com.camera2app D/CameraView: Surface created
12-19 16:00:33.964 29863-29863/ngc.com.camera2app D/CameraView: display surface changed dimensions are
12-19 16:00:33.964 29863-29863/ngc.com.camera2app D/CameraView: width : 176 | height : 144
12-19 16:00:33.973 29863-29863/ngc.com.camera2app I/CameraController: Attempting to open camera
12-19 16:00:34.048 29863-29929/ngc.com.camera2app I/CameraController: Camera 0 is open for business
12-19 16:00:34.055 29863-29863/ngc.com.camera2app W/PathParser: Points are too far apart 4.000000596046461
12-19 16:00:34.065 29863-29929/ngc.com.camera2app D/CameraView: Camera ready
12-19 16:00:48.343 29863-29929/ngc.com.camera2app I/CameraController: Image available
private synchronized void openCamera(){
if(displayReady && previewReady){
try {
List<Surface> displaySurfaces = new ArrayList<>();
//uncommenting this line adds a nasty bug
displaySurfaces.add(mPreviewView.getHolder().getSurface());
List<Surface> previewSurfaces = new ArrayList<>();
previewSurfaces.add(mCapturedTile.getHolder().getSurface());
mCameraController.openCamera(displaySurfaces, previewSurfaces);
} catch (CameraAccessException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
谢谢@eddytalvala,原来这个问题是由于分辨率不匹配。预览面:3264 x 2446显示面:176 x 148
我在中间会面,将这两项决议都改为640,480项,这解决了问题。
嗨,我有一个map-reduce程序,它在每个递归步骤中获取reducer的输出。但我还需要在每次递归中输出另一个结果。 输入1--- 输出1--- 输出2--- 输出3--- 作为我需要的最终输出:输出11,输出22,输出33,输出44和输出4 像这样,每个步骤都有两个输出文件,其中一个用于下一次迭代,另一个用于输出。 我正在使用序列文件作为文本输入格式。 任何帮助,谢谢。
问题内容: 我下面有以下代码示例。你可以在其中输入的命令,即回显结果。但是,先读后。其他输出流不起作用? 为什么会这样或我做错了什么?我的最终目标是创建一个线程计划任务,该任务定期执行对/ bash的命令,因此必须一前一后工作,而不能停止工作。我也一直在经历错误的任何想法? 谢谢。 问题答案: 首先,我建议更换生产线 与线 ProcessBuilder是Java 5中的新增功能,它使运行外部进程更
我正在尝试解决一个路由问题,如下所示: 我们有许多“任务”,每个任务都包含许多需要工人收集的项目 我的问题是如何使用或工具实现以下解算器: 允许每个工人“卸载”在仓库收集的物品并继续下一次行程 到目前为止,我已经尝试: 将n个任务中出现的相同项目视为n个不同的节点(反映在距离矩阵中,这些n个节点之间的距离设置为0) 很抱歉问了这么长的问题,谢谢,请帮忙! 更新:我使用了AddDisconction
给定一个将消息发布到两个不同主题的Kafka流拓扑,是否可以保证在这两个分支中执行各个步骤的顺序,或者这些分支是完全分开并并行执行的? 在本例中,是否会在调用< code>mapTwo或向output-topic-two发布消息之前执行< code>mapOne并发布到output-topic-one?换句话说,能否保证在消息发布到output-topic-two之前完成< code>mapOne
我正在通过一些示例学习Akka HTTP堆栈来创建一个新的REST项目(完全非UI)。我一直在使用和扩展Akka HTTP微服务示例,以通过一系列用例和配置来工作,并对Scala和Akka HTTP的良好工作感到惊喜。 目前我有一个这样的配置: 参数只是一个简单的值,其中包含使用、等的典型数据。 有没有什么方法可以在多个Scala文件或某个示例中设置路由? 这可能是我想得太多了,因为我是如何在Ja
Spring能做那样的事吗?当它只映射一件事时,我让它很容易工作。例如: @RequestMapping(“Hello-World”) 工作并将匹配/hello-world.do,/anything/hello-world.do,但我的问题是,如果hello-world位于/blog路径中,我将只匹配hello-world,并且每当我使用类似: 这看起来应该可以工作(这是我唯一的请求映射),但是:
问题内容: 是否可以实时获取PL / SQL的输出?我有一个相当大的程序包,可以运行一个多小时,我想看看该程序包在特定时间的位置。 无论如何,我目前使用一个日志表来执行此操作,该表每次运行都充满了数百个日志描述,我很好奇这是否可行。 谢谢! 问题答案: 我不知道这是否正是您想要的,但是我使用dbms_application_info.set_module来查看我的包在哪里。 出现查询将向您显示该过
问题内容: 我进行了很多搜索,但找不到任何东西。.我只是想问一下是否有任何方法可以创建和调用不带参数的过程( Informix )。我知道如何返回一个或多个值(用于过程和函数),但这不是我想要的。如果Informix不允许输出参数,那将真的很奇怪。 提前致谢! 编辑 :是的,我看到了可能,但是我仍然无法执行这样的过程。例如: 我收到的是: 常规mytest无法解决 并且仅在执行具有输出参数的功能时