欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Unity實(shí)現(xiàn)紅酒識(shí)別的示例代碼

 更新時(shí)間:2022年02月11日 14:54:36   作者:CoderZ1010  
本文主要介紹了如何通過Unity實(shí)現(xiàn)紅酒識(shí)別,可以實(shí)現(xiàn)識(shí)別圖像中的紅酒標(biāo)簽,返回紅酒名稱、國(guó)家、產(chǎn)區(qū)、酒莊、類型、糖分、葡萄品種、酒品描述等信息,感興趣的可以學(xué)習(xí)一下

接口介紹:

識(shí)別圖像中的紅酒標(biāo)簽,返回紅酒名稱、國(guó)家、產(chǎn)區(qū)、酒莊、類型、糖分、葡萄品種、酒品描述等信息,可識(shí)別數(shù)十萬中外紅酒;支持自定義紅酒圖庫,在自建庫中搜索特定紅酒信息。

創(chuàng)建應(yīng)用:     

在產(chǎn)品服務(wù)中搜索圖像識(shí)別,創(chuàng)建應(yīng)用,獲取AppID、APIKey、SecretKey信息:

查閱官方文檔,以下是紅酒識(shí)別接口返回?cái)?shù)據(jù)參數(shù)詳情:

定義數(shù)據(jù)結(jié)構(gòu):

using System;
 
[Serializable]
public class RedwineRecognition
{
    /// <summary>
    /// 請(qǐng)求標(biāo)識(shí)碼,隨機(jī)數(shù),唯一
    /// </summary>
    public float log_id;
    /// <summary>
    /// 識(shí)別結(jié)果
    /// </summary>
    public RedwineRecognitionResult result;
}
 
/// <summary>
/// 識(shí)別結(jié)果
/// </summary>
[Serializable]
public class RedwineRecognitionResult
{
    /// <summary>
    /// 判斷是否返回詳細(xì)信息(除紅酒中文名之外的其他字段),含有返回1,不含有返回0
    /// </summary>
    public int hasdetail;
    /// <summary>
    /// 紅酒中文名,無法識(shí)別返回空
    /// </summary>
    public string wineNameCn;
    /// <summary>
    /// 紅酒英文名,hasdetail = 0時(shí),表示無法識(shí)別,該字段不返回
    /// </summary>
    public string wineNameEn;
    /// <summary>
    /// 國(guó)家中文名,hasdetail = 0時(shí),表示無法識(shí)別,該字段不返回
    /// </summary>
    public string countryCn;
    /// <summary>
    /// 國(guó)家英文名,hasdetail = 0時(shí),表示無法識(shí)別,該字段不返回
    /// </summary>
    public string countryEn;
    /// <summary>
    /// 產(chǎn)區(qū)中文名,hasdetail = 0時(shí),表示無法識(shí)別,該字段不返回
    /// </summary>
    public string regionCn;
    /// <summary>
    /// 產(chǎn)區(qū)英文名,hasdetail = 0時(shí),表示無法識(shí)別,該字段不返回
    /// </summary>
    public string regionEn;
    /// <summary>
    /// 子產(chǎn)區(qū)中文名,hasdetail = 0時(shí),表示無法識(shí)別,該字段不返回
    /// </summary>
    public string subRegionCn;
    /// <summary>
    /// 子產(chǎn)區(qū)英文名,hasdetail = 0時(shí),表示無法識(shí)別,該字段不返回
    /// </summary>
    public string subRegionEn;
    /// <summary>
    /// 酒莊中文名,hasdetail = 0時(shí),表示無法識(shí)別,該字段不返回
    /// </summary>
    public string wineryCn;
    /// <summary>
    /// 酒莊英文名,hasdetail = 0時(shí),表示無法識(shí)別,該字段不返回
    /// </summary>
    public string wineryEn;
    /// <summary>
    /// 酒類型,hasdetail = 0時(shí),表示無法識(shí)別,該字段不返回
    /// </summary>
    public string classifyByColor;
    /// <summary>
    /// 糖分類型,hasdetail = 0時(shí),表示無法識(shí)別,該字段不返回
    /// </summary>
    public string classifyBySugar;
    /// <summary>
    /// 色澤,hasdetail = 0時(shí),表示無法識(shí)別,該字段不返回
    /// </summary>
    public string color;
    /// <summary>
    /// 葡萄品種,可能有多種葡萄,hasdetail = 0時(shí),表示無法識(shí)別,該字段不返回
    /// </summary>
    public string grapeCn;
    /// <summary>
    /// 葡萄品種英文名,可能有多種葡萄,hasdetail = 0時(shí),表示無法識(shí)別,該字段不返回
    /// </summary>
    public string grapeEn;
    /// <summary>
    /// 品嘗溫度,hasdetail = 0時(shí),表示無法識(shí)別,該字段不返回
    /// </summary>
    public string tasteTemperature;
    /// <summary>
    /// 酒品描述,hasdetail = 0時(shí),表示無法識(shí)別,該字段不返回
    /// </summary>
    public string description;
}

下載C# SDK:

下載完成后將AipSdk.dll動(dòng)態(tài)庫導(dǎo)入到Unity中:

以下是調(diào)用接口時(shí)傳入的參數(shù)詳情:

封裝調(diào)用函數(shù): 

using System;
using System.Collections.Generic;
using UnityEngine;
 
/// <summary>
/// 圖像識(shí)別
/// </summary>
public class ImageRecognition 
{
    //以下信息于百度開發(fā)者中心控制臺(tái)創(chuàng)建應(yīng)用獲取
    private const string appID = "";
    private const string apiKey = "";
    private const string secretKey = "";
 
    /// <summary>
    /// 紅酒識(shí)別
    /// </summary>
    /// <param name="bytes">圖片字節(jié)數(shù)據(jù)</param>
    /// <returns></returns>
    public static RedwineRecognition Redwine(byte[] bytes)
    {
        var client = new Baidu.Aip.ImageClassify.ImageClassify(apiKey, secretKey);
        try
        {
            var response = client.Redwine(bytes);
            RedwineRecognition redwineRecognition = JsonConvert.DeserializeObject<RedwineRecognition>(response.ToString());
            return redwineRecognition;
        }
        catch (Exception error)
        {
            Debug.LogError(error);
        }
        return null;
    }
    /// <summary>
    /// 紅酒識(shí)別
    /// </summary>
    /// <param name="url">圖片url地址</param>
    /// <returns></returns>
    public static RedwineRecognition Redwine(string url)
    {
        var client = new Baidu.Aip.ImageClassify.ImageClassify(apiKey, secretKey);
        try
        {
            var response = client.RedwineUrl(url);
            RedwineRecognition redwineRecognition = JsonConvert.DeserializeObject<RedwineRecognition>(response.ToString());
            return redwineRecognition;
        }
        catch (Exception error)
        {
            Debug.LogError(error);
        }
        return null;
    }
}

測(cè)試圖片:

using System.IO;
using UnityEngine;
 
public class Example : MonoBehaviour
{
    private void Start()
    {
        ImageRecognition.Redwine(File.ReadAllBytes(Application.dataPath + "/Picture.jpg"));
    }
}

到此這篇關(guān)于Unity實(shí)現(xiàn)紅酒識(shí)別的示例代碼的文章就介紹到這了,更多相關(guān)Unity紅酒識(shí)別內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • C#實(shí)現(xiàn)UI控件輸出日志的方法詳解

    C#實(shí)現(xiàn)UI控件輸出日志的方法詳解

    一般情況下,我們的日志文件是用來記錄一些關(guān)鍵操作或者異常,并且是后臺(tái)存儲(chǔ),并不對(duì)外開放的,但是也有些時(shí)候,需要將一些操作步驟、記錄等直接顯示在窗體上。本文就將利用UI控件輸出日志效果,需要的可以參考一下
    2022-10-10
  • C#實(shí)現(xiàn)設(shè)置電腦顯示器參數(shù)

    C#實(shí)現(xiàn)設(shè)置電腦顯示器參數(shù)

    這篇文章主要為大家詳細(xì)介紹了如何利用C#實(shí)現(xiàn)設(shè)置電腦顯示器參數(shù),文中的示例代碼講解詳細(xì),對(duì)我們學(xué)習(xí)C#有一定的幫助,感興趣的小伙伴可以跟隨小編一起了解一下
    2022-12-12
  • C#中數(shù)組段用法實(shí)例分析

    C#中數(shù)組段用法實(shí)例分析

    這篇文章主要介紹了C#中數(shù)組段用法,實(shí)例分析了C#數(shù)組段的定義、功能及使用方法,需要的朋友可以參考下
    2015-05-05
  • C#把文件上傳到服務(wù)器中的指定地址

    C#把文件上傳到服務(wù)器中的指定地址

    這篇文章介紹了C#實(shí)現(xiàn)文件上傳到服務(wù)器指定地址的方法,文中通過示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-04-04
  • c#方法重寫和隱藏的學(xué)習(xí)示例

    c#方法重寫和隱藏的學(xué)習(xí)示例

    最近正在學(xué)習(xí)c#,對(duì)其中的方法重寫和隱藏的概念很是模糊,現(xiàn)在將其歸納如下供大家參考
    2014-01-01
  • Unity3D 單例模式和靜態(tài)類的使用詳解

    Unity3D 單例模式和靜態(tài)類的使用詳解

    這篇文章主要介紹了Unity3D 單例模式和靜態(tài)類的使用詳解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2021-04-04
  • C#實(shí)現(xiàn)將一個(gè)矩陣分解為對(duì)稱矩陣與反稱矩陣之和的方法

    C#實(shí)現(xiàn)將一個(gè)矩陣分解為對(duì)稱矩陣與反稱矩陣之和的方法

    這篇文章主要介紹了C#實(shí)現(xiàn)將一個(gè)矩陣分解為對(duì)稱矩陣與反稱矩陣之和的方法,較為詳細(xì)的分析了矩陣分解運(yùn)算的原理與C#實(shí)現(xiàn)技巧,需要的朋友可以參考下
    2015-08-08
  • C#運(yùn)算符重載用法實(shí)例分析

    C#運(yùn)算符重載用法實(shí)例分析

    這篇文章主要介紹了C#運(yùn)算符重載用法,實(shí)例分析了C#中運(yùn)算符重載的基本實(shí)現(xiàn)與使用技巧,需要的朋友可以參考下
    2015-07-07
  • C#生成帶logo的二維碼

    C#生成帶logo的二維碼

    帶logo的二維碼生成分為兩步驟:首先根據(jù)輸入的內(nèi)容生成二維碼圖片,然后讀取本地的logo圖片,通過圖片處理生成帶logo的二維碼。本文對(duì)此進(jìn)行介紹,具有很好的參考價(jià)值,下面跟著小編一起來看下吧
    2017-02-02
  • C#處理MySql多個(gè)返回集的方法

    C#處理MySql多個(gè)返回集的方法

    這篇文章主要介紹了C#處理MySql多個(gè)返回集的方法,實(shí)現(xiàn)了對(duì)處理MySql多個(gè)返回集進(jìn)行封裝,是非常實(shí)用的技巧,需要的朋友可以參考下
    2014-12-12

最新評(píng)論