可以同时绑定Preview、ImageAnalysis、吗?VideoCapture成对组合时,所有可能的组合(即Preview+ ImageAnalysis、Preview+VideoCapture和ImageAnalysis+ VideoCapture)都工作得很好,但将所有三个组合在一起会引发以下异常。
java.lang.IllegalArgumentException: No supported surface combination is found for camera device - Id : 1. May be attempting to bind too many use cases.
at androidx.camera.camera2.internal.Camera2DeviceSurfaceManager.getSuggestedResolutions(Camera2DeviceSurfaceManager.java:193)
at androidx.camera.core.CameraX.calculateSuggestedResolutions(CameraX.java:943)
at androidx.camera.core.CameraX.bindToLifecycle(CameraX.java:293)
at androidx.camera.lifecycle.ProcessCameraProvider.bindToLifecycle(ProcessCameraProvider.java:229)
Run Code Online (Sandbox Code Playgroud)
是否有任何解决方法可以让我使用ImageAnalysis并同时录制视频?
我已经构建了一个非常简单的原生Android UI组件,我想在单击来自我的本机项目的按钮时更新其子视图的大小.更确切地说,当单击此按钮时,我向我发送命令SimpleViewManager,然后调用resizeLayout()我的自定义视图.
我可以验证是否resizeLayout()已正确调用,但在旋转手机之前不会调整布局大小.显然,更改设备的方向会触发draw()我的自定义视图,但invalidate()我明确调用的也是如此.
其他布局更改,如更改背景颜色而不是调整大小工作正常.
我的自定义组件如下所示:
public class CustomComponent extends RelativeLayout {
public CustomComponent(Context context) {
super(context);
init();
}
public CustomComponent(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public CustomComponent(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
private void init() {
inflate(getContext(), R.layout.simple_layout, this);
}
public void resizeLayout(){
LinearLayout childLayout = (LinearLayout) findViewById(R.id.child_layout);
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) childLayout.getLayoutParams();
layoutParams.height = 50;
layoutParams.width= 50;
childLayout.setLayoutParams(layoutParams); …Run Code Online (Sandbox Code Playgroud) 有没有办法使用 查询可用的相机分辨率CameraX?随着Camera2这是可能使用StreamConfigurationMap.getOutputSizes() 。但是,我找不到使用CameraX.
文档已经过时并没有帮助。目前它引用了版本,1.0.0-alpha06并且许多 API 在最新的1.0.0-beta01.
编辑:
有一种方法可以使用Camera2API获得可用的分辨率(感谢下面的 Wasim 回答)。但是,这只有在相机绑定到生命周期之后才有可能,因此无法再更改目标分辨率,这使得它非常无用。
当然,我可以在不知道可用分辨率的情况下指定目标分辨率,但这样我就无法控制最终的纵横比。在我的情况下,我最终得到了 16:9Preview和 4:3,ImageAnalysis尽管targetResolution我的ImageAnalysis是 16:9 (224x126)。
作为记录,这是获得输出大小的方法:
val camera = cameraProvider.bindToLifecycle(this, cameraSelector, preview, imageAnalyzer)
val cameraId = Camera2CameraInfo.extractCameraId(camera.cameraInfo)
val cameraManager = context.getSystemService(Context.CAMERA_SERVICE) as CameraManager
val characteristics = cameraManager.getCameraCharacteristics(cameraId)
val streamConfigurationMap = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP)
val outputSizes = streamConfigurationMap.getOutputSizes(format)
Run Code Online (Sandbox Code Playgroud)
仍在寻找实际解决方案。提前致谢。
我在设置父子pom文件的java编译器版本时面临问题.我在版本为1.7的子pom中添加了maven-compiler-plugin,并注意到java版本从默认值1.5更改为1.7,而子模块的父版本仍为1.5.然后,我将编译器插件从子pom移动到父pom.预计父级和子级maven模块的编译器版本将更改为1.7.但奇怪的是没有观察到任何变化,子模块仍然是1.7,父项目是1.5.我从eclipse IDE执行了'maven-> update project'.但没用 仅供参考:建立亲子项目工作正常,没有任何问题.有帮助吗?这是我的父母和孩子的POM
http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mymaven.parentpom.example</groupId>
<artifactId>ParentPOMProj</artifactId>
<packaging>pom</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>ParentPOMProj</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>ParentPOMProj</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<compilerVersion>1.7</compilerVersion>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<modules>
<module>ModuleOne</module>
</modules>
</project>
Run Code Online (Sandbox Code Playgroud)
http://maven.apache.org/xsd/maven-4.0.0.xsd"xmlns ="http://maven.apache.org/POM/4.0.0"xmlns:xsi ="http:// www. w3.org/2001/XMLSchema-instance"> 4.0.0
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mymaven.parentpom.example</groupId>
<artifactId>ParentPOMProj</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>com.mymaven.parentpom.example.module</groupId>
<artifactId>ModuleOne</artifactId>
<version>0.0.2-SNAPSHOT</version>
<name>ModuleOne</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> …Run Code Online (Sandbox Code Playgroud) 我为Android编写了一个原生UI组件,它基本上由一个自定义视图(RelativeLayout)组成,后者又包含JWPlayer.组件以及播放器本身都在我的RN项目中正确呈现(尺寸,颜色等具有正确的值)但是当我开始播放时,我得到没有任何图像的声音.
然而,当我旋转手机时,我也得到视频图像,一切似乎都运行正常.我在Android项目中尝试了类似的东西invalidate(),requestLayout()但没有任何改变.我还尝试render()在RN组件中再次调用(通过更新其状态),其中包含本机组件但仍然没有运气.我创建了一个原生Android项目,其中包含与我编写的完全相同的自定义RelativeLayout的Activity,一切正常.所以问题似乎是在React Native项目的一边.
由于旋转手机后一切正常,必须有一些生命周期方法重新渲染/重新布局RN组件.
所以我的问题是:有这样的方法吗?
首先十分感谢.
PS.JWPlayer基于ExoPlayer.
有没有人在 Android 和 iOS 的 React Native 应用程序中集成了 twitter 登录。任何帮助都受到高度赞赏。
react-native twitter-login react-native-android react-native-ios
android ×4
react-native ×3
eclipse ×1
exoplayer ×1
java ×1
javascript ×1
jwplayer ×1
maven ×1
maven-plugin ×1