camera-overlay 相关问题


缩放Qt3D的相机

如何实现Qt3D Camera的FOV的两指捏合手势处理? 有 FirstPersonCameraController 和 OrbitCameraController 相机控制器处理鼠标/触摸板事件。


如何在React Native Vision Camera中更改照片的宽度和高度或裁剪它?

我只是想获得一个方形图像并尽可能减小图像的尺寸,同时保持图像文本清晰。 这是我的尝试,但它不起作用。 const capturePhoto = async () =>...


为什么我的全景切换按钮不起作用?

我正在尝试制作一个按钮,以便将其绑定到全景图中的特定位置。也就是说,当用户观看 360 度全景图时,按钮不应旋转。 我正在尝试制作一个按钮,以便将其绑定到全景图中的特定位置。也就是说,当用户查看 360 度全景图时,按钮不应旋转。 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>panoramas</title> <script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script> <style> #switchButton { cursor: pointer; } </style> </head> <body> <a-scene> <a-assets> <img id="panorama1" src="1.jpg"> <img id="panorama2" src="2.jpg"> </a-assets> <a-sky id="panorama" src="#panorama1" rotation="0 -130 0"></a-sky> <a-entity id="cameraRig"> <a-camera></a-camera> </a-entity> <a-plane position="0 0 -4" rotation="-90 0 0" width="4" height="4" color="#CCC" id="switchButton"></a-plane> </a-scene> <script> const button = document.querySelector('#switchButton'); let currentPanorama = 1; button.addEventListener('mouseenter', () => { const panorama = document.querySelector('#panorama'); if (currentPanorama === 1) { panorama.setAttribute('src', '#panorama2'); currentPanorama = 2; } else { panorama.setAttribute('src', '#panorama1'); currentPanorama = 1; } }); </script> </body> </html> 我正在尝试制作一个按钮,以便将其绑定到全景图中的特定位置。也就是说,当用户查看 360 度全景图时,按钮不应旋转。 我解决你的问题 您需要做的是添加一个光标来处理 onlcick 事件,这是唯一的方法。 <html> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1.0,user-scalable=no,maximum-scale=1,width=device-width"> <title>A-Frame HTML Shader - Dynamic</title> <script src="https://aframe.io/releases/0.5.0/aframe.min.js"></script> <script src="https://unpkg.com/[email protected]/dist/aframe-html-shader.min.js"></script> <script> let currentPanorama = 1; AFRAME.registerComponent("click-log", { init: function () { this.myFunction = function () { const panorama = document.querySelector('#panorama'); if (currentPanorama === 1) { panorama.setAttribute('src', '#panorama2'); currentPanorama = 2; } else { panorama.setAttribute('src', '#panorama1'); currentPanorama = 1; } }; this.el.addEventListener("click", this.myFunction); }, remove: function () { this.el.removeEventListener("click", this.myFunction); } }); </script> </head> <body> <a-scene update-html> <a-camera> <a-cursor material="color: red"></a-cursor> </a-camera> <a-assets> <img id="panorama1" src="https://l13.alamy.com/360/PWNBM9/testing-new-cameralens-combination-in-my-garden-in-aarhus-denmark-PWNBM9.jpg"> <img id="panorama2" src="https://aframe.io/aframe/examples/boilerplate/panorama/puydesancy.jpg"> </a-assets> <a-sky id="panorama" src="#panorama1" rotation="0 -130 0"></a-sky> <a-entity id="cameraRig"> <a-camera></a-camera> </a-entity> <a-plane click-log position="0 0 -4" rotation="-90 0 0" width="4" height="4" color="#CCC" id="switchButton"></a-plane> </a-scene> </body> </html>


hasSystemFeature(PackageManager.FEATURE_CAMERA) 对于没有相机的设备返回 true

我有一个使用相机功能的应用程序,但其部分功能也可以在没有相机功能的情况下运行。所以我已将其放入我的清单中。 我有一个使用相机功能的应用程序,但其部分功能也可以在没有相机功能的情况下运行。所以我已将其放入我的清单中。 <uses-permission android:name="android.permission.CAMERA" /> <uses-feature android:name="android.hardware.camera" android:required="false"/> 在我的代码中,我使用此功能检查设备是否有摄像头 final boolean deviceHasCameraFlag = pm.hasSystemFeature(PackageManager.FEATURE_CAMERA); 现在我正在运行 Android 4.0(ICS) 并且没有摄像头的平板电脑上测试我的代码。但我仍然得到 deviceHasCameraFlag 的真实值。这很奇怪还是我错过了什么? 我尝试了不同的方法,甚至在蓝牙功能上尝试了相同的方法,因为平板电脑甚至没有蓝牙功能。它适用于蓝牙,但适用于相机。 它是什么设备?你得到的答案是一个错误,4.0 现在已经很老了。许多仍然运行此版本的平板电脑制作不正确,硬件和软件都存在多个问题。 无论如何,您应该始终准备好处理 Camera.open() 或 Camera.open(0) 上的故障:例如,在某些情况下,设备上的其他软件不会正常释放相机。 因此,在您的情况下,您有误报,您尝试打开相机,但失败了,并且您继续,就像设备上没有相机一样,即使PackageManager认为PackageManager.FEATURE_CAMERA可用。 虽然我已经接受了 Alex 的答案,但我想把这个答案放在这里,展示如何处理硬件故障和错误。 我的发现是在我的低标准 Android 设备的情况下 pm.hasSystemFeature(PackageManager.FEATURE_CAMERA) 即使相机不存在并且似乎是设备错误,也会返回 true。 所以每当有场景需要检查设备上是否存在摄像头时,请参考下面的解决方案来了解如何处理此类故障 int numberOfCameras = Camera.getNumberOfCameras(); context = this; PackageManager pm = context.getPackageManager(); final boolean deviceHasCameraFlag = pm.hasSystemFeature(PackageManager.FEATURE_CAMERA); if( !deviceHasCameraFlag || numberOfCameras==0 ) { Log.e(TAG, "Device has no camera" + numberOfCameras); Toast.makeText(getApplicationContext(), "Device has no camera", Toast.LENGTH_SHORT).show(); captureButton.setEnabled(false); } else { Log.e(TAG, "Device has camera" + deviceHasCameraFlag + numberOfCameras); } 在此,我要检查摄像头的数量以及设备是否具有摄像头功能布尔值,因此即使系统返回一个不正确的值,另一个条件也将有助于纠正代码。 就我而言,我有以下代码: public boolean hasCameraSupport() { boolean hasSupport = false; if(getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY)) { //<- this constant caused problems hasSupport = true; } return hasSupport; } 并且它在运行 Android 4.1.1 (API 16) 的 Genymotion 设备上不断返回 false。一旦我将常数 PackageManager.FEATURE_CAMERA_ANY 更改为 PackageManager.FEATURE_CAMERA,我的问题就消失了。我猜测并非所有设备/API 级别都支持PackageManager.FEATURE_CAMERA_ANY。 我明白了,你一定会尝试这个,它肯定会起作用...... import android.hardware.Camera; int numCameras = Camera.getNumberOfCameras(); if (numCameras > 0) { System.out.println("camera"); } else { System.out.println("No Camera"); } 对于CameraX,如果设备上没有Camera时FEATURE_CAMERA_ANY方法仍然返回true,您可以添加以下方法。因此,当 CameraX 初始化时,无论 FEATURE_CAMERA_ANY 返回 true 还是 false,如果相机实际上在设备上不可用,下面的方法将确保执行您想要的操作。 private CameraSelector cameraSelector; private ProcessCameraProvider cameraAvailableCheck; private ListenableFuture<ProcessCameraProvider> cameraAvailableCheckFuture; private void checkIfAnyCameraExist() { cameraAvailableCheckFuture = ProcessCameraProvider.getInstance(context); cameraAvailableCheckFuture.addListener(new Runnable() { @Override public void run() { try { cameraAvailableCheck = cameraAvailableCheckFuture.get(); if ((cameraAvailableCheck.hasCamera(cameraSelector.DEFAULT_BACK_CAMERA) || cameraAvailableCheck.hasCamera(cameraSelector.DEFAULT_FRONT_CAMERA) )) { //Do what you want if at least back OR front camera exist } else { //Do what you want if any camera does not exist } } catch (ExecutionException | InterruptedException | CameraInfoUnavailableException e) { // No errors need to be handled for this Future. // This should never be reached. } } }, ContextCompat.getMainExecutor(this)); } 请尝试此代码: private boolean isDeviceSupportCamera() { if (getApplicationContext().getPackageManager().hasSystemFeature( PackageManager.FEATURE_CAMERA)) { // this device has a camera return true; } else { // no camera on this device return false; } } 还是不行请告诉我


MAUI 8 - 如何更改弹出背景叠加颜色?

使用 MAUI 7.0,下一个代码允许更改弹出背景叠加颜色,但该代码不适用于 MAUI 8.0 使用 MAUI 7.0,下一个代码允许更改弹出窗口背景覆盖颜色,但该代码不适用于 MAUI 8.0 <maui:MauiWinUIApplication x:Class="TestMaui8.WinUI.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:maui="using:Microsoft.Maui" xmlns:local="using:TestMaui8.WinUI"> <maui:MauiWinUIApplication.Resources> <Color x:Key="SystemAltMediumColor">Transparent</Color> <SolidColorBrush x:Key="SystemControlPageBackgroundMediumAltMediumBrush" Color="{StaticResource SystemAltMediumColor}" /> <SolidColorBrush x:Key="ContentDialogBackgroundThemeBrush" Color="{StaticResource SystemAltMediumColor}" /> <SolidColorBrush x:Key="ContentDialogDimmingThemeBrush" Color="{StaticResource SystemAltMediumColor}" /> <StaticResource x:Key="ContentDialogBackground" ResourceKey="SystemControlPageBackgroundMediumAltMediumBrush" /> <StaticResource x:Key="PopupLightDismissOverlayBackground" ResourceKey="SystemControlPageBackgroundMediumAltMediumBrush" /> <SolidColorBrush x:Key="SliderBorderBrush" Color="#1A73E8" /> <Style TargetType="Slider"> <Setter Property="BorderBrush" Value="{StaticResource SliderBorderBrush}"/> </Style> </maui:MauiWinUIApplication.Resources> </maui:MauiWinUIApplication> 有人知道为什么它不起作用以及如何修复它吗? 更新添加一些图片 CommunityToolkit Popup 没有 Overlay color 功能。您可以在 CommunityToolkit GitHub 页面上提出功能请求。 是的,您发布的上述代码曾经可以工作,但它不适用于具有最新 CommunityToolkit.Maui nuget 的 .NET8。 但是如果您想更改叠加颜色,这里有一个解决方法。 <toolkit:Popup xmlns="http://schemas.microsoft.com/dotnet/2021/maui" ... Color="Black" xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit" > //make the size to be the full screen size <ContentView WidthRequest="1920" HeightRequest="1080"> <VerticalStackLayout WidthRequest="300" HeightRequest="300" BackgroundColor="Green"> <Image Source="dotnet_bot.png"/> <Label Text="Welcome to .NET MAUI!" VerticalOptions="Center" HorizontalOptions="Center" /> </VerticalStackLayout> </ContentView> </toolkit:Popup>


© www.soinside.com 2019 - 2024. All rights reserved.