XR和Steam VR项目合并问题

最近有一个项目是用Steam VR开发的,里面部分场景是用VRTK框架做的,还有一部分是用SteamVR SDK自带的Player预制直接开发的。

这样本身没有问题,因为最终都是通过SteamVR SDK处理的,VRTK也管理好了SteamVR的逻辑,并且支持动态切换,比如切换成Oculus的。

然后现在遇到一个问题,还有一个项目是用Unity自带的XR开发的,Package Manager导入XR相关的插件实现的。

 

需要将XR开发的项目移植到Steam VR项目来,然后事情就开始了。

SteamVR的场景可以运行,通过Pico以及Quest串流还有htc头盔都能正常识别,手柄也能控制。

但是XR场景就出现问题了,头盔无法识别。

经过一步步排查,发现是XR Plug-in Management这里需要设置不同的XRLoader。

而SteamVR是OpenVR Loader,而XR是OpenXR,因为OpenVR Loader在前,所以激活的是OpenVR Loader,这也是为什么SteamVR场景可以运行而XR场景不行。

我们看看unity的源代码是怎么写的,发现这里面是有activeLoader的概念,也就是一次只能一个Loader运行。

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;using UnityEditor;using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.UIElements;
using UnityEngine.Serialization;
using UnityEngine.XR.Management;[assembly: InternalsVisibleTo("Unity.XR.Management.Tests")]
[assembly: InternalsVisibleTo("Unity.XR.Management.EditorTests")]
namespace UnityEngine.XR.Management
{/// <summary>/// Class to handle active loader and subsystem management for XR. This class is to be added as a/// ScriptableObject asset in your project and should only be referenced by the <see cref="XRGeneralSettings"/>/// instance for its use.////// Given a list of loaders, it will attempt to load each loader in the given order. The first/// loader that is successful wins and all remaining loaders are ignored. The loader/// that succeeds is accessible through the <see cref="activeLoader"/> property on the manager.////// Depending on configuration the <see cref="XRManagerSettings"/> instance will automatically manage the active loader/// at correct points in the application lifecycle. The user can override certain points in the active loader lifecycle/// and manually manage them by toggling the <see cref="automaticLoading"/> and <see cref="automaticRunning"/>/// properties. Disabling <see cref="automaticLoading"/> implies the the user is responsible for the full lifecycle/// of the XR session normally handled by the <see cref="XRManagerSettings"/> instance. Toggling this to false also toggles/// <see cref="automaticRunning"/> false.////// Disabling <see cref="automaticRunning"/> only implies that the user is responsible for starting and stopping/// the <see cref="activeLoader"/> through the <see cref="StartSubsystems"/> and <see cref="StopSubsystems"/> APIs.////// Automatic lifecycle management is executed as follows////// * Runtime Initialize -> <see cref="InitializeLoader"/>. The loader list will be iterated over and the first successful loader will be set as the active loader./// * Start -> <see cref="StartSubsystems"/>. Ask the active loader to start all subsystems./// * OnDisable -> <see cref="StopSubsystems"/>. Ask the active loader to stop all subsystems./// * OnDestroy -> <see cref="DeinitializeLoader"/>. Deinitialize and remove the active loader./// </summary>public sealed class XRManagerSettings : ScriptableObject{[HideInInspector]bool m_InitializationComplete = false;#pragma warning disable 414// This property is only used by the scriptable object editing part of the system and as such no one// directly references it. Have to manually disable the console warning here so that we can// get a clean console report.[HideInInspector][SerializeField]bool m_RequiresSettingsUpdate = false;
#pragma warning restore 414[SerializeField][Tooltip("Determines if the XR Manager instance is responsible for creating and destroying the appropriate loader instance.")][FormerlySerializedAs("AutomaticLoading")]bool m_AutomaticLoading = false;/// <summary>/// Get and set Automatic Loading state for this manager. When this is true, the manager will automatically call/// <see cref="InitializeLoader"/> and <see cref="DeinitializeLoader"/> for you. When false <see cref="automaticRunning"/>/// is also set to false and remains that way. This means that disabling automatic loading disables all automatic behavior/// for the manager./// </summary>public bool automaticLoading{get { return m_AutomaticLoading; }set { m_AutomaticLoading = value; }}[SerializeField][Tooltip("Determines if the XR Manager instance is responsible for starting and stopping subsystems for the active loader instance.")][FormerlySerializedAs("AutomaticRunning")]bool m_AutomaticRunning = false;/// <summary>/// Get and set automatic running state for this manager. When set to true the manager will call <see cref="StartSubsystems"/>/// and <see cref="StopSubsystems"/> APIs at appropriate times. When set to false, or when <see cref="automaticLoading"/> is false/// then it is up to the user of the manager to handle that same functionality./// </summary>public bool automaticRunning{get { return m_AutomaticRunning; }set { m_AutomaticRunning = value; }}[SerializeField][Tooltip("List of XR Loader instances arranged in desired load order.")][FormerlySerializedAs("Loaders")]List<XRLoader> m_Loaders = new List<XRLoader>();// Maintains a list of registered loaders that is immutable at runtime.[SerializeField][HideInInspector]HashSet<XRLoader> m_RegisteredLoaders = new HashSet<XRLoader>();/// <summary>/// List of loaders currently managed by this XR Manager instance./// </summary>/// <remarks>/// Modifying the list of loaders at runtime is undefined behavior and could result in a crash or memory leak./// Use <see cref="activeLoaders"/> to retrieve the currently ordered list of loaders. If you need to mutate/// the list at runtime, use <see cref="TryAddLoader"/>, <see cref="TryRemoveLoader"/>, and/// <see cref="TrySetLoaders"/>./// </remarks>[Obsolete("'XRManagerSettings.loaders' property is obsolete. Use 'XRManagerSettings.activeLoaders' instead to get a list of the current loaders.")]public List<XRLoader> loaders{get { return m_Loaders; }
#if UNITY_EDITORset { m_Loaders = value; }
#endif}/// <summary>/// A shallow copy of the list of loaders currently managed by this XR Manager instance./// </summary>/// <remarks>/// This property returns a read only list. Any changes made to the list itself will not affect the list/// used by this XR Manager instance. To mutate the list of loaders currently managed by this instance,/// use <see cref="TryAddLoader"/>, <see cref="TryRemoveLoader"/>, and/or <see cref="TrySetLoaders"/>./// </remarks>public IReadOnlyList<XRLoader> activeLoaders => m_Loaders;/// <summary>/// Read only boolean letting us know if initialization is completed. Because initialization is/// handled as a Coroutine, people taking advantage of the auto-lifecycle management of XRManager/// will need to wait for init to complete before checking for an ActiveLoader and calling StartSubsystems./// </summary>public bool isInitializationComplete{get { return m_InitializationComplete; }}///<summary>/// Return the current singleton active loader instance.///</summary>[HideInInspector]public XRLoader activeLoader { get; private set; }/// <summary>/// Return the current active loader, cast to the requested type. Useful shortcut when you need/// to get the active loader as something less generic than XRLoader./// </summary>////// <typeparam name="T">Requested type of the loader</typeparam>////// <returns>The active loader as requested type, or null.</returns>public T ActiveLoaderAs<T>() where T : XRLoader{return activeLoader as T;}/// <summary>/// Iterate over the configured list of loaders and attempt to initialize each one. The first one/// that succeeds is set as the active loader and initialization immediately terminates.////// When complete <see cref="isInitializationComplete"/> will be set to true. This will mark that it is safe to/// call other parts of the API. This does not guarantee that init successfully created a loader. For that/// you need to check that ActiveLoader is not null.////// Note that there can only be one active loader. Any attempt to initialize a new active loader with one/// already set will cause a warning to be logged and immediate exit of this function.////// This method is synchronous and on return all state should be immediately checkable.////// <b>If manual initialization of XR is being done, this method can not be called before Start completes/// as it depends on graphics initialization within Unity completing.</b>/// </summary>public void InitializeLoaderSync(){if (activeLoader != null){Debug.LogWarning("XR Management has already initialized an active loader in this scene." +" Please make sure to stop all subsystems and deinitialize the active loader before initializing a new one.");return;}foreach (var loader in currentLoaders){if (loader != null){if (CheckGraphicsAPICompatibility(loader) && loader.Initialize()){activeLoader = loader;m_InitializationComplete = true;return;}}}activeLoader = null;}/// <summary>/// Iterate over the configured list of loaders and attempt to initialize each one. The first one/// that succeeds is set as the active loader and initialization immediately terminates.////// When complete <see cref="isInitializationComplete"/> will be set to true. This will mark that it is safe to/// call other parts of the API. This does not guarantee that init successfully created a loader. For that/// you need to check that ActiveLoader is not null.////// Note that there can only be one active loader. Any attempt to initialize a new active loader with one/// already set will cause a warning to be logged and immediate exit of this function.////// Iteration is done asynchronously and this method must be called within the context of a Coroutine.////// <b>If manual initialization of XR is being done, this method can not be called before Start completes/// as it depends on graphics initialization within Unity completing.</b>/// </summary>////// <returns>Enumerator marking the next spot to continue execution at.</returns>public IEnumerator InitializeLoader(){if (activeLoader != null){Debug.LogWarning("XR Management has already initialized an active loader in this scene." +" Please make sure to stop all subsystems and deinitialize the active loader before initializing a new one.");yield break;}foreach (var loader in currentLoaders){if (loader != null){if (CheckGraphicsAPICompatibility(loader) && loader.Initialize()){activeLoader = loader;m_InitializationComplete = true;yield break;}}yield return null;}activeLoader = null;}/// <summary>/// Attempts to append the given loader to the list of loaders at the given index./// </summary>/// <param name="loader">/// The <see cref="XRLoader"/> to be added to this manager's instance of loaders./// </param>/// <param name="index">/// The index at which the given <see cref="XRLoader"/> should be added. If you set a negative or otherwise/// invalid index, the loader will be appended to the end of the list./// </param>/// <returns>/// <c>true</c> if the loader is not a duplicate and was added to the list successfully, <c>false</c>/// otherwise./// </returns>/// <remarks>/// This method behaves differently in the Editor and during runtime/Play mode. While your app runs in the Editor and not in/// Play mode, attempting to add an <see cref="XRLoader"/> will always succeed and register that loader's type/// internally. Attempting to add a loader during runtime/Play mode will trigger a check to see whether a loader of/// that type was registered. If the check is successful, the loader is added. If not, the loader is not added and the method/// returns <c>false</c>./// </remarks>public bool TryAddLoader(XRLoader loader, int index = -1){if (loader == null || currentLoaders.Contains(loader))return false;#if UNITY_EDITORif (!EditorApplication.isPlaying && !m_RegisteredLoaders.Contains(loader))m_RegisteredLoaders.Add(loader);
#endifif (!m_RegisteredLoaders.Contains(loader))return false;if (index < 0 || index >= currentLoaders.Count)currentLoaders.Add(loader);elsecurrentLoaders.Insert(index, loader);return true;}/// <summary>/// Attempts to remove the first instance of a given loader from the list of loaders./// </summary>/// <param name="loader">/// The <see cref="XRLoader"/> to be removed from this manager's instance of loaders./// </param>/// <returns>/// <c>true</c> if the loader was successfully removed from the list, <c>false</c> otherwise./// </returns>/// <remarks>/// This method behaves differently in the Editor and during runtime/Play mode. During runtime/Play mode, the loader/// will be removed with no additional side effects if it is in the list managed by this instance. While in the/// Editor and not in Play mode, the loader will be removed if it exists and/// it will be unregistered from this instance and any attempts to add it during/// runtime/Play mode will fail. You can re-add the loader in the Editor while not in Play mode./// </remarks>public bool TryRemoveLoader(XRLoader loader){var removedLoader = true;if (currentLoaders.Contains(loader))removedLoader = currentLoaders.Remove(loader);#if UNITY_EDITORif (!EditorApplication.isPlaying && !currentLoaders.Contains(loader))m_RegisteredLoaders.Remove(loader);
#endifreturn removedLoader;}/// <summary>/// Attempts to set the given loader list as the list of loaders managed by this instance./// </summary>/// <param name="reorderedLoaders">/// The list of <see cref="XRLoader"/>s to be managed by this manager instance./// </param>/// <returns>/// <c>true</c> if the loader list was set successfully, <c>false</c> otherwise./// </returns>/// <remarks>/// This method behaves differently in the Editor and during runtime/Play mode. While in the Editor and not in/// Play mode, any attempts to set the list of loaders will succeed without any additional checks. During/// runtime/Play mode, the new loader list will be validated against the registered <see cref="XRLoader"/> types./// If any loaders exist in the list that were not registered at startup, the attempt will fail./// </remarks>public bool TrySetLoaders(List<XRLoader> reorderedLoaders){var originalLoaders = new List<XRLoader>(activeLoaders);
#if UNITY_EDITORif (!EditorApplication.isPlaying){registeredLoaders.Clear();currentLoaders.Clear();foreach (var loader in reorderedLoaders){if (!TryAddLoader(loader)){TrySetLoaders(originalLoaders);return false;}}return true;}
#endifcurrentLoaders.Clear();foreach (var loader in reorderedLoaders){if (!TryAddLoader(loader)){currentLoaders = originalLoaders;return false;}}return true;}private bool CheckGraphicsAPICompatibility(XRLoader loader){GraphicsDeviceType deviceType = SystemInfo.graphicsDeviceType;List<GraphicsDeviceType> supportedDeviceTypes = loader.GetSupportedGraphicsDeviceTypes(false);// To help with backward compatibility, if the compatibility list is empty we assume that it does not implement the GetSupportedGraphicsDeviceTypes method// Therefore we revert to the previous behavior of building or starting the loader regardless of gfx api settings.if (supportedDeviceTypes.Count > 0 && !supportedDeviceTypes.Contains(deviceType)){Debug.LogWarning(String.Format("The {0} does not support the initialized graphics device, {1}. Please change the preffered Graphics API in PlayerSettings. Attempting to start the next XR loader.", loader.name, deviceType.ToString()));return false;}return true;}/// <summary>/// If there is an active loader, this will request the loader to start all the subsystems that it/// is managing.////// You must wait for <see cref="isInitializationComplete"/> to be set to true prior to calling this API./// </summary>public void StartSubsystems(){if (!m_InitializationComplete){Debug.LogWarning("Call to StartSubsystems without an initialized manager." +"Please make sure wait for initialization to complete before calling this API.");return;}if (activeLoader != null){activeLoader.Start();}}/// <summary>/// If there is an active loader, this will request the loader to stop all the subsystems that it/// is managing.////// You must wait for <see cref="isInitializationComplete"/> to be set to tru prior to calling this API./// </summary>public void StopSubsystems(){if (!m_InitializationComplete){Debug.LogWarning("Call to StopSubsystems without an initialized manager." +"Please make sure wait for initialization to complete before calling this API.");return;}if (activeLoader != null){activeLoader.Stop();}}/// <summary>/// If there is an active loader, this function will deinitialize it and remove the active loader instance from/// management. We will automatically call <see cref="StopSubsystems"/> prior to deinitialization to make sure/// that things are cleaned up appropriately.////// You must wait for <see cref="isInitializationComplete"/> to be set to tru prior to calling this API.////// Upon return <see cref="isInitializationComplete"/> will be rest to false;/// </summary>public void DeinitializeLoader(){if (!m_InitializationComplete){Debug.LogWarning("Call to DeinitializeLoader without an initialized manager." +"Please make sure wait for initialization to complete before calling this API.");return;}StopSubsystems();if (activeLoader != null){activeLoader.Deinitialize();activeLoader = null;}m_InitializationComplete = false;}// Use this for initializationvoid Start(){if (automaticLoading && automaticRunning){StartSubsystems();}}void OnDisable(){if (automaticLoading && automaticRunning){StopSubsystems();}}void OnDestroy(){if (automaticLoading){DeinitializeLoader();}}// To modify the list of loaders internally use `currentLoaders` as it will return a list reference rather// than a shallow copy.// TODO @davidmo 10/12/2020: remove this in next major version bump and make 'loaders' internal.internal List<XRLoader> currentLoaders{get { return m_Loaders; }set { m_Loaders = value; }}// To modify the set of registered loaders use `registeredLoaders` as it will return a reference to the// hashset of loaders.internal HashSet<XRLoader> registeredLoaders{get { return m_RegisteredLoaders; }}}
}

事情变的有趣起来,我们知道了这样的原理之后,那鱼蛋我就想着尝试下,在Runtime里动态切换行吧,SteamVR场景切换到OpenVR Loader,而XR场景切换到OpenXR,代码如下。

using System.Collections.Generic;
using Unity.XR.OpenVR;
using UnityEngine;
using UnityEngine.XR.Management;
using UnityEngine.XR.OpenXR;namespace EgoGame
{/// <summary>/// 该类有问题,废弃了/// </summary>public class AutoXRLoader:MonoBehaviour{public List<XRLoader> xrLoaders;public List<XRLoader> vrLoaders;public bool isXR;private void Awake(){SetLoader(isXR);}private void OnDestroy(){SetLoader(!isXR);}void SetLoader(bool xr){//不这样,会频繁的退出loader,VR会没画面if (xr && XRGeneralSettings.Instance.Manager.activeLoader is OpenXRLoader){return;}if (!xr && XRGeneralSettings.Instance.Manager.activeLoader is OpenVRLoader){return;}var loaders = xr ? xrLoaders : vrLoaders;Debug.Log("切换Loader:" + xr+"=="+XRGeneralSettings.Instance.Manager.activeLoader);XRGeneralSettings.Instance.Manager.DeinitializeLoader();XRGeneralSettings.Instance.Manager.TrySetLoaders(loaders);XRGeneralSettings.Instance.Manager.InitializeLoaderSync();XRGeneralSettings.Instance.Manager.StartSubsystems();}}
}

果然奏效了,XR场景能在头盔里识别并运行了,手柄也能控制。但是,切到SteamVR场景就出现了问题,Steam VR SDK报错了,报错提示有另一个应用在使用SteamVR。

最后的结果就是,没法实现动态切换XR或VR,如果看到此处的人,有办法请告诉我,我尝试了两天用了各种办法,都没法做到。

最后推荐大家开发VR应用不要直接用SteamVR SDK或XR SDK或Oculus SDK开发,而是用那些集成的插件,如VR Interaction Framework、VRTK等,这样在多个VR设备也能快速部署。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/344438.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

JVM学习-内存泄漏

内存泄漏的理解和分类 可达性分析算法来判断对象是否是不再使用的对象&#xff0c;本质都是判断一上对象是否还被引用&#xff0c;对于这种情况下&#xff0c;由于代码的实现不同就会出现很多内存泄漏问题(让JVM误以为此对象还在引用&#xff0c;无法回收&#xff0c;造成内存泄…

Redis 内存回收

文章目录 1. 过期key处理1.1 惰性删除1.2 周期删除 2. 内存淘汰策略 Redis 中数据过期策略采用定期删除惰性删除策略结合起来&#xff0c;以及采用淘汰策略来兜底。 定期删除策略&#xff1a;Redis 启用一个定时器定时监视所有的 key&#xff0c;判断key是否过期&#xff0c;过…

单片机+TN901非接触式红外测温设计

摘要 温度测量技术应用十分广泛&#xff0c;而且在现代设备故障检测领域中也是一项非常重要的技术。但在某些应用领域中&#xff0c;要求测量温度用的传感器不能与被测物体相接触&#xff0c;这就需要一种非接触的测温方式来满足上述测温需求。本论文正是应上述实际需求而设计的…

大模型,也在卷价格

“百模大战”已从算力战、规模战蔓延到了价格战。 5月15日&#xff0c;字节跳动宣布豆包主力模型&#xff08;小于等于32K&#xff09;在企业市场的定价只有0.0008元/千Tokens&#xff0c;0.8厘就能处理1500多个汉字&#xff0c;比行业便宜99.3%&#xff1b;5月21日&#xff0…

Servlet基础(续集)

Servlet原理 Servlet是由Web服务器调用&#xff0c;Web服务器在收到浏览器请求之后&#xff0c;会&#xff1a; Mapping问题 一个Servlet可以指定一个映射路径 <servlet-mapping><servlet-name>hello</servlet-name><url-pattern>/hello</url-pa…

Scikit-Learn随机森林分类

Scikit-Learn随机森林分类 1、随机森林分类1.1、随机森林分类概述1.2、随机森林分类的优缺点2、Scikit-Learn随机森林分类2.1、Scikit-Learn随机森林分类API2.2、Scikit-Learn随机森林分类初体验(葡萄酒分类)2.3、Scikit-Learn随机森林分类实践(鸢尾花分类)2.4、参数调优与…

苹果将推出“Apple Intelligence”AI系统,专注于隐私和广泛应用|TodayAI

据彭博社报道&#xff0c;苹果公司将在下周的 WWDC 2024 开发者大会上揭晓其全新的 AI 系统——“Apple Intelligence”&#xff0c;该系统将适用于 iPhone、iPad 和 Mac 设备。这一新系统将结合苹果自身技术和 OpenAI 的工具&#xff0c;为用户提供一系列新的 AI 功能&#xf…

vscode输出控制台中文显示乱码最有效解决办法

当VSCode的输出控制台中文显示乱码时&#xff0c;一个有效的解决办法是通过设置环境变量来确保编码的正确性。以下是解决方式&#xff1a; 首先&#xff0c;设置环境变量以修正乱码问题&#xff1a; 如果上述方法没有解决乱码问题&#xff0c;请继续以下步骤&#xff1a; 右键…

C语言详解(动态内存管理)2

Hi~&#xff01;这里是奋斗的小羊&#xff0c;很荣幸您能阅读我的文章&#xff0c;诚请评论指点&#xff0c;欢迎欢迎 ~~ &#x1f4a5;&#x1f4a5;个人主页&#xff1a;奋斗的小羊 &#x1f4a5;&#x1f4a5;所属专栏&#xff1a;C语言 &#x1f680;本系列文章为个人学习…

数据结构--线性表和串

个人介绍 hello hello~ &#xff0c;这里是 code袁~&#x1f496;&#x1f496; &#xff0c;欢迎大家点赞&#x1f973;&#x1f973;关注&#x1f4a5;&#x1f4a5;收藏&#x1f339;&#x1f339;&#x1f339; &#x1f981;作者简介&#xff1a;一名喜欢分享和记录学习的…

用 Notepad++ 写 Java 程序

安装包 百度网盘 提取码&#xff1a;6666 安装步骤 双击安装包开始安装。 安装完成&#xff1a; 配置编码 用 NotePad 写 Java 程序时&#xff0c;需要设置编码。 在 设置&#xff0c;首选项&#xff0c;新建 中进行设置&#xff0c;可以对每一个新建的文件起作用。 Note…

ElasticSearch教程(详解版)

本篇博客将向各位详细介绍elasticsearch&#xff0c;也算是对我最近学完elasticsearch的一个总结&#xff0c;对于如何在Kibana中使用DSL指令&#xff0c;本篇文章不会进行介绍&#xff0c;这里只会介绍在java中如何进行使用&#xff0c;保证你看完之后就会在项目中进行上手&am…

3072. 将元素分配到两个数组中 II

题目 给你一个下标从 1 开始、长度为 n 的整数数组 nums 。 现定义函数 greaterCount &#xff0c;使得 greaterCount(arr, val) 返回数组 arr 中 严格大于 val 的元素数量。 你需要使用 n 次操作&#xff0c;将 nums 的所有元素分配到两个数组 arr1 和 arr2 中。在第一次操…

四十二、openlayers官网示例Flight Animation扩展——在地图上绘制飞机航线、飞机随航线飞行效果

上篇在地图上绘制了动态的飞机航线&#xff0c;于是我想着&#xff0c;能不能加个飞机的图标跟着航线飞行。 在iconfont上下载一个飞机的svg图形&#xff0c;放在public的data/icons下面 因为图标需要随着航线的方向飞行&#xff0c;需要根据航线调整角度&#xff0c;因此在…

FPGA SPI采集ADC7606数据

一,SPI总线的构成及信号类型 SPI总线只需四条线(如图1所示)就可以完成MCU与各种外围器件的通讯: 1)MOSI – Master数据输出,Slave数据输入 2)MISO – Master数据输入,Slave数据输出 3)SCK – 时钟信号,由Master产生 4)/CS – Slave使能信号,由Master控制。 在一个SPI时…

递归【2】(组合回溯(生成括号)、子集回溯(背包问题))

括号对 &#xff08;组合型回溯&#xff09; 分解成子问题&#xff0c;每一次添加括号分两步&#xff1a; if左括号小于n&#xff0c;加左括号&#xff0c;然后k(index1), if左括号大于有括号&#xff0c;加右括号&#xff0c;k(index1),然后收尾括号单独考虑&#xff0c;到…

core dump核心转储

检查核心转储是否开启&#xff0c;否则无法生成core文件 ulimit -a 如果为0就需要修改 ulimit -c 10240 写一个会触发core命令的程序 以浮点数运算为例 #include <iostream>int main() {int i 1/0; } 在编译时使用-g选项 运行程序&#xff0c;生成core文件 gdb调试 g…

AI大模型在广告领域的应用

深度对谈&#xff1a;广告创意领域中AIGC的应用_生成式 AI_Tina_InfoQ精选文章

ChatGPT-4o, 腾讯元宝,通义千问对比测试中文文化

国内的大模型应用我选择了国内综合实力最强的两个&#xff0c;一个是腾讯元宝&#xff0c;一个是通义千问。其它的豆包&#xff0c;Kimi&#xff0c;文心一言等在某些领域也有强于竞品的表现。 问一个中文文化比较基础的问题,我满以为中文文化chatGPT不如国内的大模型。可事实…

【经典排序算法】堆排序(精简版)

什么是堆排序&#xff1a; 堆排序(Heapsort)是指利用堆&#xff08;完全二叉树&#xff09;这种数据结构所设计的一种排序算法&#xff0c;它是选择排序的一种。需要注意的是排升序要建大堆&#xff0c;排降序建小堆。 堆排序排序的特性总结&#xff1a; 1. 堆排序使用堆来选数…