主頁 >  其他 > 6步帶你用Spring Boot開發出商城高并發秒殺系統

6步帶你用Spring Boot開發出商城高并發秒殺系統

2023-04-07 07:43:55 其他

摘要:本博客將介紹如何使用 Spring Boot 實作一個簡單的商城秒殺系統,并通過使用 Redis 和 MySQL 來增強其性能和可靠性,

本文分享自華為云社區《Spring Boot實作商城高并發秒殺案例》,作者:林欣,

隨著經濟的發展和人們消費觀念的轉變,電子商務逐漸成為人們購物的主要方式之一,高并發是電子商務網站面臨的一個重要挑戰,本博客將介紹如何使用 Spring Boot 實作一個簡單的商城秒殺系統,并通過使用 Redis 和 MySQL 來增強其性能和可靠性,

準備作業

在開始之前,您需要準備以下工具和環境:

  • JDK 1.8 或更高版本
  • Redis
  • MySQL
  • MyBatis

實作步驟

步驟一:創建資料庫

首先,我們需要創建一個資料庫來存盤商品資訊、訂單資訊和秒殺活動資訊,在這里,我們使用 MySQL 資料庫,創建一個名為 shop 的資料庫,并建立三個表 goods、order 和 seckill,

表 goods 存盤了所有的商品資訊,包括商品編號、名稱、描述、價格和庫存數量等等,

CREATE TABLE `goods` (
 `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '商品ID',
 `name` varchar(50) NOT NULL COMMENT '商品名稱',
 `description` varchar(100) NOT NULL COMMENT '商品描述',
 `price` decimal(10,2) NOT NULL COMMENT '商品價格',
 `stock_count` int(11) NOT NULL COMMENT '商品庫存',
 PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='商品表';

表 order 存盤了所有的訂單資訊,包括訂單編號、用戶ID、商品ID、秒殺活動ID 和訂單狀態等等,

CREATE TABLE `order` (
 `id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '訂單ID',
 `user_id` BIGINT(20) NOT NULL COMMENT '用戶ID',
 `goods_id` BIGINT(20) NOT NULL COMMENT '商品ID',
 `seckill_id` BIGINT(20) DEFAULT NULL COMMENT '秒殺活動ID',
 `status` TINYINT(4) NOT NULL COMMENT '訂單狀態,0-未支付,1-已支付,2-已發貨,3-已識訓,4-已退款,5-已完成',
 `create_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '創建時間',
 `update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新時間',
 PRIMARY KEY (`id`),
 UNIQUE KEY `unique_order` (`user_id`,`goods_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='訂單表';

表 seckill 存盤了所有的秒殺活動資訊,包括秒殺活動編號、商品ID、開始時間和結束時間等等,

CREATE TABLE `seckill` (
 `id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '秒殺活動ID',
 `goods_id` BIGINT(20) NOT NULL COMMENT '商品ID',
 `start_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '開始時間',
 `end_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '結束時間',
 PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='秒殺活動表';

步驟二:創建 Spring Boot 專案

接下來,我們需要創建一個 Spring Boot 專案,用于實作商城高并發秒殺案例,可以使用 Spring Initializr 來快速創建一個基本的 Spring Boot 專案,

步驟三:配置 Redis 和 MySQL

在 Spring Boot 專案中,我們需要配置 Redis 和 MySQL 的連接資訊,可以在 application.properties 檔案中設定以下屬性:

spring.redis.host=127.0.0.1
spring.redis.port=6379
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/shop?serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true
spring.datasource.username=root
spring.datasource.password=123456

步驟四:撰寫物體類和 DAO 介面

在這一步中,我們需要定義三個物體類分別對應資料庫中的 goods、order 和 seckill 表,同時,我們需要撰寫相應的 DAO 介面,用于操作這些物體類,

// 商品物體類
@Data
public class Goods {
 private Long id;
 private String name;
 private String description;
 private BigDecimal price;
 private Integer stockCount;
}
// 商品 DAO 介面
@Mapper
public interface GoodsDao {
    @Select("SELECT * FROM goods WHERE id = #{id}")
    Goods getGoodsById(Long id);
    @Update("UPDATE goods SET stock_count = stock_count - 1 WHERE id = #{id} AND stock_count > 0")
    int reduceStockCount(Long id);
}
// 訂單物體類
@Data
public class Order {
 private Long id;
 private Long userId;
 private Long goodsId;
 private Long seckillId;
 private Byte status;
 private Date createTime;
 private Date updateTime;
}
// 訂單 DAO 介面
@Mapper
public interface OrderDao {
    @Select("SELECT * FROM `order` WHERE user_id = #{userId} AND goods_id = #{goodsId}")
    Order getOrderByUserIdAndGoodsId(@Param("userId") Long userId, @Param("goodsId") Long goodsId);
    @Insert("INSERT INTO `order` (user_id, goods_id, seckill_id, status, create_time, update_time) VALUES (#{userId}, #{goodsId}, #{seckillId}, #{status},#{createTime},#{updateTime})")
    int insertOrder(Order order);
    @Select("SELECT o.*, g.name, g.price FROM `order` o LEFT JOIN goods g ON o.goods_id = g.id WHERE o.user_id = #{userId}")
    List<OrderVo> getOrderListByUserId(Long userId);
}
// 秒殺活動物體類
@Data
public class Seckill {
 private Long id;
 private Long goodsId;
 private Date startTime;
 private Date endTime;
}
// 秒殺活動 DAO 介面
@Mapper
public interface SeckillDao {
    @Select("SELECT * FROM seckill WHERE id = #{id}")
    Seckill getSeckillById(Long id);
    @Update("UPDATE seckill SET end_time = #{endTime} WHERE id = #{id}")
    int updateSeckillEndTime(@Param("id") Long id, @Param("endTime") Date endTime);
}

步驟五:撰寫 Service 層和 Controller

在這一步中,我們需要撰寫 Service 層和 Controller 類,用于實作商城高并發秒殺案例的核心功能,

  • 商品 Service 層:用于獲取商品資訊和減少商品庫存數量,
@Service
public class GoodsService {
 private final GoodsDao goodsDao;
    @Autowired
 public GoodsService(GoodsDao goodsDao) {
 this.goodsDao = goodsDao;
 }
 public Goods getGoodsById(Long id) {
 return goodsDao.getGoodsById(id);
 }
 public boolean reduceStockCount(Long id) {
 return goodsDao.reduceStockCount(id) > 0;
 }
}
  • 訂單 Service 層:用于創建訂單和獲取訂單資訊,
@Service
public class OrderService {
 private final OrderDao orderDao;
    @Autowired
 public OrderService(OrderDao orderDao) {
 this.orderDao = orderDao;
 }
 public Order createOrder(Long userId, Long goodsId, Long seckillId) {
        Order order = new Order();
        order.setUserId(userId);
        order.setGoodsId(goodsId);
        order.setSeckillId(seckillId);
        order.setStatus((byte) 0);
        order.setCreateTime(new Date());
        order.setUpdateTime(new Date());
        orderDao.insertOrder(order);
 return order;
 }
 public List<OrderVo> getOrderListByUserId(Long userId) {
 return orderDao.getOrderListByUserId(userId);
 }
}
  • 秒殺活動 Service 層:用于獲取秒殺活動資訊和更新秒殺活動結束時間,
@Service
public class SeckillService {
 private final SeckillDao seckillDao;
    @Autowired
 public SeckillService(SeckillDao seckillDao) {
 this.seckillDao = seckillDao;
 }
 public Seckill getSeckillById(Long id) {
 return seckillDao.getSeckillById(id);
 }
 public boolean updateSeckillEndTime(Long id, Date endTime) {
 return seckillDao.updateSeckillEndTime(id, endTime) > 0;
 }
}
  • 訂單 Controller:用于處理訂單相關的請求,
@RestController
@RequestMapping("/order")
public class OrderController {
 private final OrderService orderService;
    @Autowired
 public OrderController(OrderService orderService) {
 this.orderService = orderService;
 }
    @PostMapping("/create")
 public CommonResult<Order> createOrder(@RequestParam("userId") Long userId,
                                           @RequestParam("goodsId") Long goodsId,
                                           @RequestParam("seckillId") Long seckillId) {
        Order order = orderService.createOrder(userId, goodsId, seckillId);
 if (order == null) {
 return CommonResult.failed(ResultCode.FAILURE);
 }
 return CommonResult.success(order);
 }
    @GetMapping("/list")
 public CommonResult<List<OrderVo>> getOrderListByUserId(@RequestParam("userId") Long userId) {
        List<OrderVo> orderList = orderService.getOrderListByUserId(userId);
 return CommonResult.success(orderList);
 }
}

秒殺活動 Controller:用于處理秒殺活動相關的請求,

@RestController
@RequestMapping("/seckill")
public class SeckillController {
 private final SeckillService seckillService;
 private final GoodsService goodsService;
 private final OrderService orderService;
    @Autowired
 public SeckillController(SeckillService seckillService, GoodsService goodsService, OrderService orderService) {
 this.seckillService = seckillService;
 this.goodsService = goodsService;
 this.orderService = orderService;
 }
    @PostMapping("/start")
 public CommonResult<Object> startSeckill(@RequestParam("userId") Long userId,
                                             @RequestParam("goodsId") Long goodsId,
                                             @RequestParam("seckillId") Long seckillId) {
 // 查詢秒殺活動是否有效
        Seckill seckill = seckillService.getSeckillById(seckillId);
 if (seckill == null || seckill.getStartTime().after(new Date()) || seckill.getEndTime().before(new Date())) {
 return CommonResult.failed(ResultCode.FAILURE, "秒殺活動不存在或已結束");
 }
 // 判斷商品庫存是否充足
        Goods goods = goodsService.getGoodsById(goodsId);
 if (goods == null || goods.getStockCount() <= 0) {
 return CommonResult.failed(ResultCode.FAILURE, "商品庫存不足");
 }
 // 生成訂單
        Order order = orderService.createOrder(userId, goodsId, seckillId);
 if (order == null) {
 return CommonResult.failed(ResultCode.FAILURE, "訂單創建失敗,請稍后再試");
 }
 // 減少商品庫存
        boolean success = goodsService.reduceStockCount(goodsId);
 if (!success) {
 return CommonResult.failed(ResultCode.FAILURE, "減少商品庫存失敗,請稍后再試");
 }
 return CommonResult.success("秒殺成功");
 }
}

步驟六:使用 Redis 實作分布式鎖

在商城高并發秒殺案例中,一個重要的問題是如何保證商品庫存數量的一致性和秒殺結果的正確性,為了解決這個問題,我們可以使用 Redis 實作分布式鎖,

在 RedisService 類中實作分布式鎖:

@Service
public class RedisService {
 private final RedisTemplate<String, Object> redisTemplate;
    @Autowired
 public RedisService(RedisTemplate<String, Object> redisTemplate) {
 this.redisTemplate = redisTemplate;
 }
 public boolean lock(String key, String value, long expire) {
        Boolean result = redisTemplate.opsForValue().setIfAbsent(key, value, Duration.ofSeconds(expire));
 return result != null && result;
 }
 public void unlock(String key, String value) {
 if (value.equals(redisTemplate.opsForValue().get(key))) {
            redisTemplate.delete(key);
 }
 }
}

在 SeckillService 中使用分布式鎖實作秒殺介面:

@Service
public class SeckillService {
 private final RedisService redisService;
 private final SeckillDao seckillDao;
 private final GoodsDao goodsDao;
 private final OrderDao orderDao;
    @Autowired
 public SeckillService(RedisService redisService, SeckillDao seckillDao, GoodsDao goodsDao, OrderDao orderDao) {
 this.redisService = redisService;
 this.seckillDao = seckillDao;
 this.goodsDao = goodsDao;
 this.orderDao = orderDao;
 }
 public CommonResult<Object> startSeckill(Long userId, Long goodsId, Long seckillId) {
        String lockKey = "seckill:lock:" + goodsId;
        String lockValue = UUID.randomUUID().toString();
 try {
 // 獲取分布式鎖
 if (!redisService.lock(lockKey, lockValue, 10)) {
 return CommonResult.failed(ResultCode.FAILURE, "當前請求太過頻繁,請稍后再試");
 }
 // 查詢秒殺活動是否有效
            Seckill seckill = seckillDao.getSeckillById(seckillId);
 if (seckill == null || seckill.getStartTime().after(new Date()) || seckill.getEndTime().before(new Date())) {
 return CommonResult.failed(ResultCode.FAILURE, "秒殺活動不存在或已結束");
 }
 // 判斷商品庫存是否充足
            Goods goods = goodsDao.getGoodsById(goodsId);
 if (goods == null || goods.getStockCount() <= 0) {
 return CommonResult.failed(ResultCode.FAILURE, "商品庫存不足");
 }
 // 創建訂單
            Order order = new Order();
            order.setUserId(userId);
            order.setGoodsId(goodsId);
            order.setSeckillId(seckillId);
            order.setStatus((byte) 0);
            order.setCreateTime(new Date());
            order.setUpdateTime(new Date());
            int count = orderDao.insertOrder(order);
 if (count <= 0) {
 return CommonResult.failed(ResultCode.FAILURE, "訂單創建失敗,請稍后再試");
 }
 // 減少商品庫存
            boolean success = goodsDao.reduceStockCount(goodsId) > 0;
 if (!success) {
 throw new Exception("減少商品庫存失敗,請稍后再試");
 }
 return CommonResult.success("秒殺成功");
 } catch (Exception e) {
            e.printStackTrace();
 return CommonResult.failed(ResultCode.FAILURE, "秒殺失敗," + e.getMessage());
 } finally {
 // 釋放分布式鎖
            redisService.unlock(lockKey, lockValue);
 }
 }
}

 

點擊關注,第一時間了解華為云新鮮技術~

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/549302.html

標籤:其他

上一篇:架構師日記-如何寫的一手好代碼

下一篇:大神之路-起始篇 | 第3章.計算機科學導論之【資料存盤】學習筆記

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 網閘典型架構簡述

    網閘架構一般分為兩種:三主機的三系統架構網閘和雙主機的2+1架構網閘。 三主機架構分別為內端機、外端機和仲裁機。三機無論從軟體和硬體上均各自獨立。首先從硬體上來看,三機都用各自獨立的主板、記憶體及存盤設備。從軟體上來看,三機有各自獨立的作業系統。這樣能達到完全的三機獨立。對于“2+1”系統,“2”分為 ......

    uj5u.com 2020-09-10 02:00:44 more
  • 如何從xshell上傳檔案到centos linux虛擬機里

    如何從xshell上傳檔案到centos linux虛擬機里及:虛擬機CentOs下執行 yum -y install lrzsz命令,出現錯誤:鏡像無法找到軟體包 前言 一、安裝lrzsz步驟 二、上傳檔案 三、遇到的問題及解決方案 總結 前言 提示:其實很簡單,往虛擬機上安裝一個上傳檔案的工具 ......

    uj5u.com 2020-09-10 02:00:47 more
  • 一、SQLMAP入門

    一、SQLMAP入門 1、判斷是否存在注入 sqlmap.py -u 網址/id=1 id=1不可缺少。當注入點后面的引數大于兩個時。需要加雙引號, sqlmap.py -u "網址/id=1&uid=1" 2、判斷文本中的請求是否存在注入 從文本中加載http請求,SQLMAP可以從一個文本檔案中 ......

    uj5u.com 2020-09-10 02:00:50 more
  • Metasploit 簡單使用教程

    metasploit 簡單使用教程 浩先生, 2020-08-28 16:18:25 分類專欄: kail 網路安全 linux 文章標簽: linux資訊安全 編輯 著作權 metasploit 使用教程 前言 一、Metasploit是什么? 二、準備作業 三、具體步驟 前言 Msfconsole ......

    uj5u.com 2020-09-10 02:00:53 more
  • 游戲逆向之驅動層與用戶層通訊

    驅動層代碼: #pragma once #include <ntifs.h> #define add_code CTL_CODE(FILE_DEVICE_UNKNOWN,0x800,METHOD_BUFFERED,FILE_ANY_ACCESS) /* 更多游戲逆向視頻www.yxfzedu.com ......

    uj5u.com 2020-09-10 02:00:56 more
  • 北斗電力時鐘(北斗授時服務器)讓網路資料更精準

    北斗電力時鐘(北斗授時服務器)讓網路資料更精準 北斗電力時鐘(北斗授時服務器)讓網路資料更精準 京準電子科技官微——ahjzsz 近幾年,資訊技術的得了快速發展,互聯網在逐漸普及,其在人們生活和生產中都得到了廣泛應用,并且取得了不錯的應用效果。計算機網路資訊在電力系統中的應用,一方面使電力系統的運行 ......

    uj5u.com 2020-09-10 02:01:03 more
  • 【CTF】CTFHub 技能樹 彩蛋 writeup

    ?碎碎念 CTFHub:https://www.ctfhub.com/ 筆者入門CTF時時剛開始刷的是bugku的舊平臺,后來才有了CTFHub。 感覺不論是網頁UI設計,還是題目質量,賽事跟蹤,工具軟體都做得很不錯。 而且因為獨到的金幣制度的確讓人有一種想去刷題賺金幣的感覺。 個人還是非常喜歡這個 ......

    uj5u.com 2020-09-10 02:04:05 more
  • 02windows基礎操作

    我學到了一下幾點 Windows系統目錄結構與滲透的作用 常見Windows的服務詳解 Windows埠詳解 常用的Windows注冊表詳解 hacker DOS命令詳解(net user / type /md /rd/ dir /cd /net use copy、批處理 等) 利用dos命令制作 ......

    uj5u.com 2020-09-10 02:04:18 more
  • 03.Linux基礎操作

    我學到了以下幾點 01Linux系統介紹02系統安裝,密碼啊破解03Linux常用命令04LAMP 01LINUX windows: win03 8 12 16 19 配置不繁瑣 Linux:redhat,centos(紅帽社區版),Ubuntu server,suse unix:金融機構,證券,銀 ......

    uj5u.com 2020-09-10 02:04:30 more
  • 05HTML

    01HTML介紹 02頭部標簽講解03基礎標簽講解04表單標簽講解 HTML前段語言 js1.了解代碼2.根據代碼 懂得挖掘漏洞 (POST注入/XSS漏洞上傳)3.黑帽seo 白帽seo 客戶網站被黑帽植入劫持代碼如何處理4.熟悉html表單 <html><head><title>TDK標題,描述 ......

    uj5u.com 2020-09-10 02:04:36 more
最新发布
  • 2023年最新微信小程式抓包教程

    01 開門見山 隔一個月發一篇文章,不過分。 首先回顧一下《微信系結手機號資料庫被脫庫事件》,我也是第一時間得知了這個訊息,然后跟蹤了整件事情的經過。下面是這起事件的相關截圖以及近日流出的一萬條資料樣本: 個人認為這件事也沒什么,還不如關注一下之前45億快遞資料查詢渠道疑似在近日復活的訊息。 訊息是 ......

    uj5u.com 2023-04-20 08:48:24 more
  • web3 產品介紹:metamask 錢包 使用最多的瀏覽器插件錢包

    Metamask錢包是一種基于區塊鏈技術的數字貨幣錢包,它允許用戶在安全、便捷的環境下管理自己的加密資產。Metamask錢包是以太坊生態系統中最流行的錢包之一,它具有易于使用、安全性高和功能強大等優點。 本文將詳細介紹Metamask錢包的功能和使用方法。 一、 Metamask錢包的功能 數字資 ......

    uj5u.com 2023-04-20 08:47:46 more
  • vulnhub_Earth

    前言 靶機地址->>>vulnhub_Earth 攻擊機ip:192.168.20.121 靶機ip:192.168.20.122 參考文章 https://www.cnblogs.com/Jing-X/archive/2022/04/03/16097695.html https://www.cnb ......

    uj5u.com 2023-04-20 07:46:20 more
  • 從4k到42k,軟體測驗工程師的漲薪史,給我看哭了

    清明節一過,盲猜大家已經無心上班,在數著日子準備過五一,但一想到銀行卡里的余額……瞬間心情就不美麗了。最近,2023年高校畢業生就業調查顯示,本科畢業月平均起薪為5825元。調查一出,便有很多同學表示自己又被平均了。看著這一資料,不免讓人想到前不久中國青年報的一項調查:近六成大學生認為畢業10年內會 ......

    uj5u.com 2023-04-20 07:44:00 more
  • 最新版本 Stable Diffusion 開源 AI 繪畫工具之中文自動提詞篇

    🎈 標簽生成器 由于輸入正向提示詞 prompt 和反向提示詞 negative prompt 都是使用英文,所以對學習母語的我們非常不友好 使用網址:https://tinygeeker.github.io/p/ai-prompt-generator 這個網址是為了讓大家在使用 AI 繪畫的時候 ......

    uj5u.com 2023-04-20 07:43:36 more
  • 漫談前端自動化測驗演進之路及測驗工具分析

    隨著前端技術的不斷發展和應用程式的日益復雜,前端自動化測驗也在不斷演進。隨著 Web 應用程式變得越來越復雜,自動化測驗的需求也越來越高。如今,自動化測驗已經成為 Web 應用程式開發程序中不可或缺的一部分,它們可以幫助開發人員更快地發現和修復錯誤,提高應用程式的性能和可靠性。 ......

    uj5u.com 2023-04-20 07:43:16 more
  • CANN開發實踐:4個DVPP記憶體問題的典型案例解讀

    摘要:由于DVPP媒體資料處理功能對存放輸入、輸出資料的記憶體有更高的要求(例如,記憶體首地址128位元組對齊),因此需呼叫專用的記憶體申請介面,那么本期就分享幾個關于DVPP記憶體問題的典型案例,并給出原因分析及解決方法。 本文分享自華為云社區《FAQ_DVPP記憶體問題案例》,作者:昇騰CANN。 DVPP ......

    uj5u.com 2023-04-20 07:43:03 more
  • msf學習

    msf學習 以kali自帶的msf為例 一、msf核心模塊與功能 msf模塊都放在/usr/share/metasploit-framework/modules目錄下 1、auxiliary 輔助模塊,輔助滲透(埠掃描、登錄密碼爆破、漏洞驗證等) 2、encoders 編碼器模塊,主要包含各種編碼 ......

    uj5u.com 2023-04-20 07:42:59 more
  • Halcon軟體安裝與界面簡介

    1. 下載Halcon17版本到到本地 2. 雙擊安裝包后 3. 步驟如下 1.2 Halcon軟體安裝 界面分為四大塊 1. Halcon的五個助手 1) 影像采集助手:與相機連接,設定相機引數,采集影像 2) 標定助手:九點標定或是其它的標定,生成標定檔案及內參外參,可以將像素單位轉換為長度單位 ......

    uj5u.com 2023-04-20 07:42:17 more
  • 在MacOS下使用Unity3D開發游戲

    第一次發博客,先發一下我的游戲開發環境吧。 去年2月份買了一臺MacBookPro2021 M1pro(以下簡稱mbp),這一年來一直在用mbp開發游戲。我大致分享一下我的開發工具以及使用體驗。 1、Unity 官網鏈接: https://unity.cn/releases 我一般使用的Apple ......

    uj5u.com 2023-04-20 07:40:19 more