1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

犬猫判定機

Last updated at Posted at 2019-06-03

写真に写っているのが犬か猫かを判定する。
https://docs.google.com/spreadsheets/d/1_bmS3AP9ehGqZ8AsJJmfMwy1tU3d_Bt8GFGiU8jfXME/edit#gid=0

#使用するAPI
A3RTの「Image Search API」
https://a3rt.recruit-tech.co.jp/product/imageSearchAPI/

#コード

コード.js

function ImageConvertText(pic_link) {
 
  var res = UrlFetchApp.fetch("https://api.a3rt.recruit-tech.co.jp/image_search/v1/search_by_image?apikey=APIキー&image=" + pic_link).getContentText();  
  var json = JSON.parse(res);
  var tag = json["result"].txt;
  
  if (tag.indexOf("ネコ") != -1 | tag.indexOf("") != -1) {
    return "まんち!";
  } else if (tag.indexOf("イヌ") != -1 | tag.indexOf("") != -1) {
    return "わんち!";
  //elseだと何も言わないときがある
  } else if (tag.indexOf("イヌ") == -1 && tag.indexOf("") == -1 && tag.indexOf("ネコ") == -1 && tag.indexOf("") == -1){
    return "むり!";
  }
  
}


function Results() {
  
  var url = Browser.inputBox("画像のURLを入力");
  Browser.msgBox(ImageConvertText(url));
 
}

#やってみる

https://www.pakutaso.com/shared/img/thumb/kakurerukijishironeko171027_TP_V.jpg
Screenshot from 2019-06-03 19-33-25.png

https://www.pakutaso.com/shared/img/thumb/AMEMAN17826009_TP_V.jpg
Screenshot from 2019-06-03 19-39-04.png

https://www.pakutaso.com/shared/img/thumb/KM19322A053_TP_V.jpg
Screenshot from 2019-06-03 19-41-18.png

画像引用元
https://www.pakutaso.com/

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?