uni-app利用renderjs实现安卓App上jssip+freeswitch+webrtc音视频通话功能

news2024/12/24 3:24:30

效果图

在这里插入图片描述

前置知识

利用renderjs在app端加载for web库
JsSIP+FreeSwitch+Vue实现WebRtc音视频通话

原始模块

<template>
  <view
		class="test-sip"
		:userExtension="userExtension"
		:change:userExtension="JsSIP.handleUserExtenSionChange"
		:targetExtension="targetExtension"
		:change:targetExtension="JsSIP.handleTargetExtensionChange"
		:logFlag="logFlag"
		:change:logFlag="JsSIP.handleLogFlagChange"
		:jsSipTestLocalStream="jsSipTestLocalStream"
		:change:jsSipTestLocalStream="JsSIP.handleTestLocalStreamChange"
		:jsSipIsRegisted="jsSipIsRegisted"
		:change:jsSipIsRegisted="JsSIP.handleSipRegistedChange"
		:jsSipCallByAudio="jsSipCallByAudio"
		:change:jsSipCallByAudio="JsSIP.handleCallByAudio"
		:jsSipCallByVideo="jsSipCallByVideo"
		:change:jsSipCallByVideo="JsSIP.handleCallByVideo"
		:jsSipHangup="jsSipHangup"
		:change:jsSipHangup="JsSIP.handleJsSipHangupChange"
	>
		<view class="log-box">
			<view class="log-item" :style="`color: ${!logFlag?'#2979ff':'#333'}`">关闭日志</view>
			<u-switch class="log-item" v-model="logFlag"></u-switch>
			<view class="log-item" :style="`color: ${logFlag?'#2979ff':'#333'}`">打开日志</view>
		</view>
    <view class="step">
      <view class="step-title">步骤 1:输入自己的分机号(1001-1019)</view>
			<u--input v-model="userExtension" border="surround" placeholder="请输入自己的分机号(1001-1019)"
				:disabled="hasLocalStream" class="mb-10" :customStyle="{border: '1px solid #e0e0e0'}"
			/>
			<u-button type="primary" :disabled="!userExtension || isRegisted" @click="registerUser">注册</u-button>
    </view>

    <view class="step">
      <view class="step-title">步骤 2:输入要呼叫的分机号(1001-1019)</view>
			<u--input 
				v-model="targetExtension" border="surround" placeholder="请输入要呼叫的分机号(1001-1019)" :disabled="!isRegisted"
				class="mb-10" :customStyle="{border: '1px solid #e0e0e0'}"
			/>
			<u-button type="primary" class="mb-10" :disabled="!targetExtension || hasCurrentSession" @click="startCall(false)">拨打语音电话</u-button>
			<u-button type="primary" :disabled="!targetExtension || hasCurrentSession" @click="startCall(true)">拨打视频电话</u-button>
    </view>

    <view class="step">
      <view class="step-title">其他操作</view>
			<u-button type="primary" class="mb-10" :disabled="!hasCurrentSession" @click="jsSipHangup=true">挂断</u-button>
			<u-button type="primary" class="mb-10" :disabled="!isRegisted" @click="jsSipIsRegisted=false">取消注册</u-button>
			<u-button type="primary" v-if="!jsSipTestLocalStream" :disabled="hasCurrentSession" @click="jsSipTestLocalStream=true">测试本地设备</u-button>
			<u-button type="primary" v-else :disabled="hasCurrentSession" @click="jsSipTestLocalStream=false">停止测试本地设备</u-button>
    </view>
		
		<view class="step" id="audio-container">
			<!-- <view class="step-title">音频</view> -->
		</view>
		
		<view class="step" id="video-container">
			<view class="step-title">视频</view>
		</view>
		
		<u-notify ref="uNotify"></u-notify>
  </view>
	
</template>

<script>
import { requestCameraPermission, requestRecordAudioPermission } from '@/utils/request-android-permission.js'
export default {
  data() {
    return {
      userExtension: "", // 当前用户分机号
      targetExtension: "", // 目标用户分机号
			logFlag: false,
			hasCurrentSession: false,
			jsSipTestLocalStream: false,
			hasLocalStream: false,
			jsSipIsRegisted: false,
			isRegisted: false,
			jsSipCallByAudio: false,
			jsSipCallByVideo: false,
			jsSipHangup: false
    };
  },
	mounted() {
		requestRecordAudioPermission(() => {
			requestCameraPermission()
		})
	},
  methods: {
    isValidExtension(extension) {
      const extNumber = parseInt(extension, 10);
      return extNumber >= 1001 && extNumber <= 1019;
    },
    registerUser() {
      if (!this.isValidExtension(this.userExtension)) {
        this.showError("分机号无效,请输入1001-1019之间的分机号");
        return;
      }
			this.jsSipIsRegisted = true
    },
    startCall(flag) {
      if (!this.isValidExtension(this.targetExtension)) {
        this.showError("分机号无效,请输入1001-1019之间的分机号");
        return;
      }
			flag ? this.jsSipCallByVideo = true : this.jsSipCallByAudio = true
    },
		/* 接收 renderjs 传过来的数据 */
		reciveMessage(msgObj) {
			console.log('view reciveMsg:', msgObj);
			const { msg, data } = msgObj
			switch (msg) {
				case 'notify': 
					this.$refs.uNotify[data.type](data.message)
					break
				case 'changeViewData':
					this[data.key] = data.value === 'true' ? true : data.value === 'false' ? false : data.value
			}
		}
  },
};
</script>

<script module="JsSIP" lang="renderjs">
import renderjs from './jsSipRender.js'
export default renderjs
</script>

<style lang="scss" scoped>
.test-sip {
  padding: 30px;
	.log-box {
		display: flex;
		margin-bottom: 10px;
		
		.log-item {
			margin-right: 10px;
		}
	}
	.step {
	  margin-bottom: 20px;
		
		.mb-10 {
			margin-bottom: 10px;
		}
		.step-title {
			margin-bottom: 10px;
		}
	}
	

}



</style>

renderjs 模块

import JsSIP from 'jssip'
const testMp3 = './static/media/test.mp3'
const testMp4 = './static/media/test.mp4'

export default {
	data() {
	  return {
	    userAgent: null, // 用户代理实例
	    incomingSession: null,
			currentSession: null,
			outgoingSession: null,
	    password: "xxxxx", // 密码
	    serverIp: "xxxxxxx", // 服务器ip
			audio: null,
			meVideo: null,
			remoteVideo: null,
			localStream: null,
			constraints: {
				audio: true,
				video: {
					width: { max: 1280 },
					height: { max: 720 },
				},
			},
			myHangup: false,
	  }
	},
	computed: {
		ws_url() {
		  return `ws://${this.serverIp}:5066`;
		}
	},
	mounted() {
		this.audio = document.createElement('audio')
		this.audio.autoplay = true
		// this.audio.src = testMp3
		document.getElementById('audio-container').appendChild(this.audio)
		this.meVideo = document.createElement('video')
		this.meVideo.autoplay = true
		this.meVideo.playsinline = true
		// this.meVideo.src = testMp4
		document.getElementById('video-container').appendChild(this.meVideo)
		this.remoteVideo = document.createElement('video')
		this.remoteVideo.autoplay = true
		this.remoteVideo.playsinline = true
		// this.remoteVideo.src = testMp4
		document.getElementById('video-container').appendChild(this.remoteVideo)
		const styleObj = {
			width: '150px',
			'background-color': '#333',
			border: '2px solid blue',
			margin: '0 5px'
		}
		Object.keys(styleObj).forEach(key => {
			this.meVideo.style[key] = styleObj[key]
			this.remoteVideo.style[key] = styleObj[key]
		})
	},
	methods: {
		handleLogFlagChange(nV, oV) {
			nV ? JsSIP.debug.enable("JsSIP:*") : JsSIP.debug.disable("JsSIP:*");
			// this.log('logFlag', nV, oV)
			/* if(oV !== undefined) {
				this.log('logFlag', nV, oV)
			} */
		},
		handleUserExtenSionChange(nV, oV) {
			if(oV !== undefined) {
				// this.log('userExtenSion', nV, oV)
			}
		},
		handleTargetExtensionChange(nV, oV) {
			if(oV !== undefined) {
				// this.log('targetExtenSion', nV, oV)
			}
		},
		handleTestLocalStreamChange(nV, oV) {
			if(oV !== undefined) {
				// this.log('jsSipTestLocalStream', nV, oV)
				if(nV) {
					this.captureLocalMedia(() => {
						this.sendMsg('changeViewData', {
							key: 'hasLocalStream',
							value: true
						})
					}, (e) => {
						this.sendMsg('changeViewData', {
							key: 'jsSipTestLocalStream',
							value: false
						})
						this.sendMsg('notify', {
							type: 'error',
							message: "getUserMedia() error: " + e.name
						})
					})
				} else {
					this.stopLocalMedia()
					this.sendMsg('changeViewData', {
						key: 'jsSipTestLocalStream',
						value: false
					})
				}
			}
		},
		handleSipRegistedChange(nV, oV) {
			if(oV !== undefined) {
				if(nV) {
					this.registerUser()
				} else {
					this.unregisterUser()
				}
			}
		},
		handleCallByAudio(nV, oV) {
			if(oV !== undefined) {
				if(nV) {
					this.startCall(false)
				}
			}
		},
		handleCallByVideo(nV, oV) {
			if(oV !== undefined) {
				if(nV) {
					this.startCall(true)
				}
			}
		},
		handleJsSipHangupChange(nV, oV) {
			if(oV !== undefined) {
				if(nV) {
					this.hangUpCall()
				}
			}
		},
		captureLocalMedia(successCb, errCb) {
			console.log("Requesting local video & audio");
			navigator.mediaDevices
				.getUserMedia(this.constraints)
				.then((stream) => {
					console.log("Received local media stream");
					this.localStream = stream;

					// 连接本地麦克风
					if ("srcObject" in this.audio) {
						this.audio.srcObject = stream;
					} else {
						this.audio.src = window.URL.createObjectURL(stream);
					}
					// 如果有视频流,则连接本地摄像头
					if (stream.getVideoTracks().length > 0) {
						if ("srcObject" in this.meVideo) {
							this.meVideo.srcObject = stream;
						} else {
							this.meVideo.src = window.URL.createObjectURL(stream);
						}
					}
					successCb()
				})
				.catch((e) => errCb(e));
		},
		stopLocalMedia() {
			if (this.localStream) {
				this.localStream.getTracks().forEach((track) => track.stop());
				this.localStream = null;
				// 清空音频和视频的 srcObject
				this.clearMedia("audio");
				this.clearMedia("meVideo");
			}
		},
		clearMedia(mediaNameOrStream) {
			let mediaSrcObject = this[mediaNameOrStream].srcObject;
			if (mediaSrcObject) {
				let tracks = mediaSrcObject.getTracks();
				for (let i = 0; i < tracks.length; i++) {
					tracks[i].stop();
				}
			}
			this[mediaNameOrStream].srcObject = null;
		},
		registerUser() {
			const configuration = {
				sockets: [new JsSIP.WebSocketInterface(this.ws_url)],
				uri: `sip:${this.userExtension}@${this.serverIp};transport=ws`,
				password: this.password,
				contact_uri: `sip:${this.userExtension}@${this.serverIp};transport=ws`,
				display_name: this.userExtension,
				register: true, //指示启动时JsSIP用户代理是否应自动注册
				session_timers: false, //关闭会话计时器(根据RFC 4028)
			};
			this.userAgent = new JsSIP.UA(configuration);
			
			this.userAgent.on("connecting", () => console.log("WebSocket 连接中"));
			this.userAgent.on("connected", () => console.log("WebSocket 连接成功"));
			this.userAgent.on("disconnected", () =>
				console.log("WebSocket 断开连接")
			);
			this.userAgent.on("registered", () => {
				console.log("用户代理注册成功");
				this.sendMsg('changeViewData', { key: 'isRegisted', value: true })
			});
			this.userAgent.on("unregistered", () => {
				console.log("用户代理取消注册");
				this.sendMsg('changeViewData', { key: 'isRegisted', value: false })
			});
			this.userAgent.on("registrationFailed", (e) => {
				this.sendMsg('notify', { type: 'error', message: '注册失败' })
			});
			
			this.userAgent.on("newRTCSession", (e) => {
				console.log("新会话: ", e);
				if (e.originator == "remote") {
					console.log("接听到来电");
					this.incomingSession = e.session;
					this.sipEventBind(e);
				} else {
					console.log("打电话");
					this.outgoingSession = e.session;

					this.outgoingSession.on("connecting", (data) => {
						console.info("onConnecting - ", data.request);
						this.currentSession = this.outgoingSession;
						this.sendMsg('changeViewData', { key: 'hasCurrentSession', value: true })
						this.outgoingSession = null;
					});
					
					this.outgoingSession.connection.addEventListener("track", (event) => {
						console.info("Received remote track:", event.track);
						this.trackHandle(event.track, event.streams[0]);
					});

					//连接到信令服务器,并恢复以前的状态,如果以前停止。重新开始时,如果UA配置中的参数设置为register:true,则向SIP域注册。
					this.userAgent.start();
					console.log("用户代理启动");
				}
			})
			
			//连接到信令服务器,并恢复以前的状态,如果以前停止。重新开始时,如果UA配置中的参数设置为register:true,则向SIP域注册。
			this.userAgent.start();
			console.log("用户代理启动");
		},
		startCall(isVideo = false) {
			if (this.userAgent) {
				try {
					const eventHandlers = {
						progress: (e) => console.log("call is in progress"),
						failed: (e) => {
							console.error(e);
							this.sendMsg('notify', {
								type: 'error',
								message: `call failed with cause: ${e.cause}`
							})
						},
						ended: (e) => {
							this.endedHandle();
							console.log(`call ended with cause: ${e.cause}`);
						},
						confirmed: (e) => console.log("call confirmed"),
					};
					console.log("this.userAgent.call");
					this.outgoingSession = this.userAgent.call(
						`sip:${this.targetExtension}@${this.serverIp}`, // :5060
						{
							mediaConstraints: { audio: true, video: isVideo },
							eventHandlers,
						}
					);
				} catch (error) {
					this.sendMsg('notify', {
						type: 'error',
						message: '呼叫失败'
					})
					console.error("呼叫失败:", error);
				}
			} else {
				this.sendMsg('notify', {
					type: 'error',
					message: '用户代理未初始化'
				})
			}
		},
		sipEventBind(remotedata, callbacks) {
			//接受呼叫时激发
			remotedata.session.on("accepted", () => {
				console.log("onAccepted - ", remotedata);
				if (remotedata.originator == "remote" && this.currentSession == null) {
					this.currentSession = this.incomingSession;
					this.sendMsg('changeViewData', { key: 'hasCurrentSession', value: true })
					this.incomingSession = null;
					console.log("setCurrentSession:", this.currentSession);
				}
			});

			//在将远程SDP传递到RTC引擎之前以及在发送本地SDP之前激发。此事件提供了修改传入和传出SDP的机制。
			remotedata.session.on("sdp", (data) => {
				console.log("onSDP, type - ", data.type, " sdp - ", data.sdp);
			});

			//接收或生成对邀请请求的1XX SIP类响应(>100)时激发。该事件在SDP处理之前触发(如果存在),以便在需要时对其进行微调,甚至通过删除数据对象中响应参数的主体来删除它
			remotedata.session.on("progress", () => {
				console.log(remotedata);
				console.log("onProgress - ", remotedata.originator);
				if (remotedata.originator == "remote") {
					console.log("onProgress, response - ", remotedata.response);
					//answer设置的自动接听
					//RTCSession 的 answer 方法做了自动接听。实际开发中,你需要弹出一个提示框,让用户选择是否接听

					const isVideoCall = remotedata.request.body.includes("m=video");
					const flag = confirm(`检测到${remotedata.request.from.display_name}${isVideoCall ? "视频" : "语音"}来电,是否接听?`);
					if(!flag) {
						this.hangUpCall();
						return;
					} else {
						//如果同一电脑两个浏览器测试则video改为false,这样被呼叫端可以看到视频,两台电脑测试让双方都看到改为true
						remotedata.session.answer({
							mediaConstraints: { audio: true, video: isVideoCall },
							// mediaStream: this.localStream,
						});
					}
				}
			});

			//创建基础RTCPeerConnection后激发。应用程序有机会通过在peerconnection上添加RTCDataChannel或设置相应的事件侦听器来更改peerconnection。
			remotedata.session.on("peerconnection", () => {
				console.log("onPeerconnection - ", remotedata.peerconnection);

				if (remotedata.originator == "remote" && this.currentSession == null) {
					//拿到远程的音频流
					/* remotedata.session.connection.addEventListener(
						"addstream",
						(event) => {
							console.info("Received remote stream:", event.stream);
							this.streamHandle(event.stream);
						}
					); */
					remotedata.session.connection.addEventListener("track", (event) => {
						console.info("Received remote track:", event.track);
						this.trackHandle(event.track, event.streams[0]);
					});
				}
			});

			//确认呼叫后激发
			remotedata.session.on("confirmed", () => {
				console.log("onConfirmed - ", remotedata);
				if (remotedata.originator == "remote" && this.currentSession == null) {
					this.currentSession = this.incomingSession;
					this.sendMsg('changeViewData', { key: 'hasCurrentSession', value: true })
					this.incomingSession = null;
					console.log("setCurrentSession - ", this.currentSession);
				}
			});

			// 挂断处理
			remotedata.session.on("ended", () => {
				this.endedHandle();
				console.log("call ended:", remotedata);
			});

			remotedata.session.on("failed", (e) => {
				this.sendMsg('notify', { type: 'error', message: '会话失败' })
				console.error("会话失败:", e);
			});
		},
		unregisterUser() {
			console.log("取消注册");
			this.userAgent.unregister();
			this.sendMsg('changeViewData', { key: 'isRegisted', value: false })
			this.sendMsg('changeViewData', { key: 'userExtension', value: '' })
			this.sendMsg('changeViewData', { key: 'targetExtension', value: '' })
		},
		trackHandle(track, stream) {
			const showVideo = () => {
				navigator.mediaDevices
					.getUserMedia({
						...this.constraints,
						audio: false, // 不播放本地声音
					})
					.then((stream) => {
						this.meVideo.srcObject = stream;
					})
					.catch((error) => {
						this.sendMsg('notify', {
							type: 'error',
							message: `${error.name}${error.message}`
						})
					});
			};
			// 根据轨道类型选择播放元素
			if (track.kind === "video") {
				// 使用 video 元素播放视频轨道
				this.remoteVideo.srcObject = stream;
				showVideo();
			} else if (track.kind === "audio") {
				// 使用 audio 元素播放音频轨道
				this.audio.srcObject = stream;
			}
		},
		endedHandle() {
			this.clearMedia("meVideo");
			this.clearMedia("remoteVideo");
			this.clearMedia("audio");
			if (this.myHangup) {
				this.sendMsg('notify', { type: 'success', message: '通话结束' })
			} else {
				this.sendMsg('notify', { type: 'warning', message: '对方已挂断!' })
			}
			this.myHangup = false;

			this.currentSession = null;
			this.sendMsg('changeViewData', { key: 'hasCurrentSession', value: false })
			this.sendMsg('changeViewData', { key: 'jsSipCallByVideo', value: false })
			this.sendMsg('changeViewData', { key: 'jsSipCallByAudio', value: false })
		},
		hangUpCall() {
			this.myHangup = true;
			this.outgoingSession = this.userAgent.terminateSessions();
			this.currentSession = null;
			this.sendMsg('changeViewData', { key: 'hasCurrentSession', value: false })
			this.sendMsg('changeViewData', { key: 'jsSipHangup', value: false })
		},
		// 日志
		log(key, nV, oV) {
			console.log(`renderjs:${key} 改变`);
			console.log(`${key} 新值:`, nV);
			console.log(`${key} 旧值:`, oV);
		},
		// 向视图层发送消息
		sendMsg(msg, data) {
			// 向页面传参
			// console.log('renderjs sendMsg:');
			// console.log(msg, data);
			
			this.$ownerInstance.callMethod('reciveMessage', {
				msg,
				data
			})
		},
	}
}

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

基于D-H参数、旋量代数、李群、李代数和微分流形的机器人建模方法

在机器人建模中&#xff0c;D-H参数、旋量代数、李群、李代数和微分流形方法为机器人运动学和动力学的精确描述提供了理论基础。旋量代数、李群李代数和微分流形”均属于“PoE &#xff08;Product of Exponentials&#xff09;表示方法”的范畴。 D-H 表示方法和 PoE 表示方法…

11.QLoRA微调ChatGLM3-6B

实战 QLoRA 微调 ChatGLM3-6B 大模型 实战 PEFT 库 QLoRA ChatGLM3-6B 微调数据集 AdvertiseGen AdvertiseGen 数据集获取 使用ChatGLM3-6b Tokenizer处理数据 关于ig nore_label_id 的设置&#xff1a; 在许多自然语言处理和机器学习框架中&#xff0c; ig nore_label_id 被…

JVM知识梳理

一 JVM 是一种规范 1.1 Java程序的执行过程 一个 Java 程序&#xff0c;首先经过 javac 编译成 .class 文件&#xff0c;然后 JVM 将其加载到方法区&#xff0c;执行引擎将会执行这些字节码。执行时&#xff0c;会翻译成操作系统相关的函数。JVM 作为 .class 文件的翻译存在…

[Algorithm][贪心][柠檬水找零][将数组和减半的最少操作次数][最大数][摆动序列]详细讲解

目录 1.柠檬水找零1.题目链接2.算法原理详解3.代码实现 2.将数组和减半的最少操作次数1.题目链接2.算法原理详解3.代码实现 3.最大数1.题目链接2.算法原理详解3.代码实现 4.摆动序列1.题目链接2.算法原理详解3.代码实现 1.柠檬水找零 1.题目链接 柠檬水找零 2.算法原理详解 …

Cisco Packet Tracer实验(一)

协议的概念 VLSM&#xff1a;可变长子网掩码&#xff08;Variable Length Subnet Mask&#xff09;没有传统意义上的A、B、C类网络&#xff0c;根据需求变化子网掩码的长度 CIDR无类别域间路由&#xff08;ClasslessInter-Domain Routing、CIDR&#xff09;把子网聚合在一起&…

多款可观测产品全面升级丨阿里云云原生 5 月产品月报

云原生月度动态 云原生是企业数字创新的最短路径。 《阿里云云原生每月动态》&#xff0c;从趋势热点、产品新功能、服务客户、开源与开发者动态等方面&#xff0c;为企业提供数字化的路径与指南。 趋势热点 &#x1f947; 阿里云云原生产品负责人李国强&#xff1a;推进可…

Eureka到Nacos迁移实战:解决配置冲突与启动异常

问题&#xff1a;Eureka到Nacos迁移实战&#xff1a;解决配置冲突与启动异常 在进行微服务架构升级&#xff0c;特别是注册中心从Eureka转向Nacos的过程中&#xff0c;我遇到了一个典型的技术挑战。目标是为了减少因配置变更导致的服务重启频率&#xff0c;我决定拥抱Nacos以其…

【PB案例学习笔记】-21小大写金额转换

写在前面 这是PB案例学习笔记系列文章的第21篇&#xff0c;该系列文章适合具有一定PB基础的读者。 通过一个个由浅入深的编程实战案例学习&#xff0c;提高编程技巧&#xff0c;以保证小伙伴们能应付公司的各种开发需求。 文章中设计到的源码&#xff0c;小凡都上传到了gite…

安装台式电脑网卡驱动

安装电脑网卡驱动 1. 概述2. 具体方法2.1 先确定主板型号2.2 详细操作步骤如下2.2.1 方法一2.2.2 方法二2.2 主流主板官网地址 结束语 1. 概述 遇到重装系统后、或者遇到网卡驱动出现问题没有网络时&#xff0c;当不知道怎么办时&#xff0c;以下的方法&#xff0c;可以作为一…

MMDetection实用工具详解(下):模型复杂度、基准测试

工具目录 四、模型复杂度应用展示结果解析 五、基准测试鲁棒性测试基准应用展示结果解析Testing gaussian_noise at severity 0Testing gaussian_noise at severity 2Aggregated results 遇到的tools自定义导包模块No Module Error错误解决思路 上期MMDetection内三个实用工具详…

2、给出五种并行计算机体系结构的名称,并分别画出其典型结构。

①并行向量处理机&#xff08;PVP&#xff09; ②对称多机系统&#xff08;SMP&#xff09; ③大规模并行处理机&#xff08;MPP&#xff09; ④分布式共享存储器多机系统&#xff08;DSM&#xff09; ⑤工作站机群&#xff08;COW&#xff09;

户外led显示屏如何选择?

在繁华的都市中&#xff0c;户外LED显示屏以其独特的魅力&#xff0c;成为传递信息、展示形象的重要工具。然而&#xff0c;面对市场上琳琅满目的产品&#xff0c;如何选择一款适合自己的户外LED显示屏呢&#xff1f;下面&#xff0c;我们将从屏幕类型、尺寸等具体参数出发&…

教程:A5000 GPU 上运行阿里最新开源大模型 Qwen2

这是我们新一篇关于大模型的文章&#xff0c;我们此前还讲过如何运行 LLama3 大模型。而这次&#xff0c;我们将使用 Ollama 运行阿里千问Qwen2:7b。要知道 Qwen2 可是目前最热门的开源大语言模型了&#xff0c;甚至在一些性能测试中比 LLama3 表现还突出。谁不想试试看呢&…

Golang | Leetcode Golang题解之第149题直线上最多的点数

题目&#xff1a; 题解&#xff1a; func maxPoints(points [][]int) (ans int) {n : len(points)if n < 2 {return n}for i, p : range points {if ans > n-i || ans > n/2 {break}cnt : map[int]int{}for _, q : range points[i1:] {x, y : p[0]-q[0], p[1]-q[1]if…

《NVIDIA-Jetson AGX Orin》移除或临时忽略 NVIDIA 仓库

阿丹&#xff1a; 开发的过程中出现了一些问题&#xff0c;在下载以及安装docker的时候&#xff0c;明明已经修改到了阿里云的国内镜像&#xff0c;但是还在下载的时候去访问了英伟达的下载仓库。在国内网络环境就会导致下载失败&#xff0c;网络不可达&#xff0c;本文章记录一…

现在Java行情不好可以转.net吗?

转向.NET开发可能是一个选择&#xff0c;但要注意以下几点。我这里有一套编程入门教程&#xff0c;不仅包含了详细的视频 讲解&#xff0c;项目实战。如果你渴望学习编程&#xff0c;不妨点个关注&#xff0c;给个评论222&#xff0c;私信22&#xff0c;我在后台发给你。 技术转…

好书推荐:生成式AI入门与AWS实战

这本书给LLM的爱好者者提供了完整的学习路线&#xff0c;让读者从使用大语言模型开始到剖析常用的技术概念&#xff0c;能够填补了机器学习爱好者从传统的文字处理到大语言模型的空白知识&#xff0c;包括显存计算优化&#xff0c;微调&#xff0c;RAG&#xff0c; 多模态&…

电池包断路单元DBU的预充电电阻应用案例

当电池组接触器闭合到电机和逆变器上时&#xff0c;逆变器电容器中会有电流涌入。这种非常高的电流至少可能会使接触器老化&#xff0c;并可能永久损坏接触器。 因此&#xff0c;当我们关闭电池组上的接触器时&#xff0c;我们分三个步骤执行此操作&#xff1a; 1.关闭主负极…

【机器学习】鸢尾花分类:机器学习领域经典入门项目实战

学习机器学习&#xff0c;就像学习任何新技能一样&#xff0c;最好的方法之一就是通过实战来巩固理论知识。鸢尾花分类项目是一个经典的入门项目&#xff0c;它不仅简单易懂&#xff0c;还能帮助我们掌握机器学习的基本步骤和方法。 鸢尾花数据集&#xff08;Iris Dataset&…

NLP入门——基于TF-IDF算法的应用

从json格式数据中抽出句子和标签 首先查看json格式的数据文件&#xff1a; :~/nlp/tnews/src$ less train.json可以看到json字符串表示一个对象&#xff0c;我们利用json.loads() 函数会将其转换为一个 Python 字典。docs python json #ext.py #encoding: utf-8import sys f…