Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Unity Code to identify Red Wine

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of "how to use Unity code to achieve red wine identification". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to use Unity code to achieve red wine identification" can help you solve the problem.

API description:

Identify the red wine label in the image, return red wine name, country, producing area, winery, type, sugar, grape variety, wine description and other information, can identify hundreds of thousands of Chinese and foreign red wines; support custom red wine map database, search for specific red wine information in the self-built database.

Create an application:

Search for image recognition in product services, create applications, and obtain AppID, APIKey, SecretKey information:

Check the official documents. The following is the details of the data parameters returned by the red wine identification API:

Define the data structure:

Using System; [Serializable] public class RedwineRecognition {/ request identification code, random number, unique / / public float log_id; / recognition result / public RedwineRecognitionResult result } / recognition result / [Serializable] public class RedwineRecognitionResult {/ determine whether to return detailed information (fields other than the Chinese name of red wine), including return 1, not return 0 / public int hasdetail; / red wine text name, unable to recognize the return empty / public string wineNameCn / the English name of red wine. If hasdetail = 0, it means it cannot be recognized. This field does not return / / public string wineNameEn; / country Chinese name. When hasdetail = 0, it means it cannot be recognized, and the field does not return / public string countryCn. / the English name of the country. If hasdetail = 0, it means it cannot be recognized. This field does not return / / public string countryEn; / the Chinese name of the production area. When hasdetail = 0, it means it is not recognized, and the field does not return / public string regionCn / the English name of the production area. If hasdetail = 0, it means it is not recognized. This field does not return / / public string regionEn; / the Chinese name of the sub-production area. When hasdetail = 0, it means it is not recognized, and the field does not return / public string subRegionCn. / the English name of the sub-production area. If hasdetail = 0, it means it is not recognized. This field does not return the Chinese name of the winery / public string subRegionEn; /. When hasdetail = 0, it means it is not recognized, and the field does not return / public string wineryCn. / the English name of the winery. If hasdetail = 0, it means it is not recognized. This field does not return / / public string wineryEn; / wine type. When hasdetail = 0, it means it is not recognized, and the field does not return / public string classifyByColor. / Sugar type. Hasdetail = 0 means it cannot be recognized. This field does not return / public string classifyBySugar; / color. When hasdetail = 0, it means it is not recognized, and this field does not return / public string color. / Grape variety. If hasdetail = 0, it means it cannot be recognized. This field does not return the English name of grape variety / public string grapeCn; /. It may have many kinds of grapes. If hasdetail = 0, it means it cannot be recognized. This field does not return / public string grapeEn. / Taste temperature. Hasdetail = 0 means unrecognized. This field does not return / public string tasteTemperature; / wine description. When hasdetail = 0, it means unrecognized. This field does not return / public string description;}.

Download C# SDK:

Import the AipSdk.dll dynamic library into Unity when the download is complete:

The following are the details of the parameters passed when the API is called:

Encapsulate the calling function:

Using System;using System.Collections.Generic;using UnityEngine; / Image recognition / public class ImageRecognition {/ / the following information is available on the Baidu developer Center console to create an application and get private const string appID = ""; private const string apiKey = ""; private const string secretKey = "" / Red wine identification / 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 (response.ToString ()); return redwineRecognition } catch (Exception error) {Debug.LogError (error);} return null;} / Red Wine Identification / Picture url address / 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 (response.ToString ()); return redwineRecognition;} catch (Exception error) {Debug.LogError (error);} return null;}}

Test picture:

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

This is the end of the introduction on "how to use Unity code to identify red wine". Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report