In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "how to achieve plant identification by Unity". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
API description:
It is suitable for taking pictures, popularizing preschool education, image content analysis and other scenes.
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 plant identification API:
Define the data structure:
Using System; / Plant identification / [Serializable] public class PlantRecognition {/ unique log id for problem location / public float log_id; / recognition result array / public PlantRecognition [] result;} [Serializable] public class PlantRecognitionResult {/ Plant name / public string name / public float score; / Encyclopedia entry / public BaikeInfo baike_info;} [Serializable] public class BaikeInfo {/ corresponding to the identification result Baidu encyclopedia page link / public string baike_url / Encyclopedia picture link / public string image_url; / Encyclopedia content description / public string description;} corresponding to the recognition result
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 = "" / Plant identification / Byte image data / the number of results returned from encyclopedia information. / public static PlantRecognition Plant (byte [] bytes, int baikeNum = 0) {var client = new Baidu.Aip.ImageClassify.ImageClassify (apiKey, secretKey) is not returned by default. Try {var options = new Dictionary {{"baike_num", baikeNum}}; var response = client.PlantDetect (bytes, options); Debug.Log (response); PlantRecognition plantRecognition = JsonConvert.DeserializeObject (response.ToString ()); return plantRecognition } catch (Exception error) {Debug.LogError (error);} return null;}}
Test picture:
Using System.IO;using UnityEngine; public class Example: MonoBehaviour {private void Start () {ImageRecognition.Plant (File.ReadAllBytes (Application.dataPath + "/ Picture.jpg");}}
This is the end of the content of "how to achieve plant identification in Unity". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.