Created
July 25, 2017 03:24
-
-
Save prats226/af4b28a87fdfe41ce5e4166b64f6617f to your computer and use it in GitHub Desktop.
Ruby gist to count number of cars using pretrained model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'uri' | |
require 'net/http' | |
require 'json' | |
appId = 'bee0b774-b81c-401a-ad0d-baf5d3eef886' | |
imageUrl = 'http://www.pngall.com/wp-content/uploads/2016/07/Car-Free-PNG-Image.png' | |
url = URI('http://app.nanonets.com/ObjectLocalize/?appId=' + appId + '&url=' + imageUrl) | |
http = Net::HTTP.new(url.host, url.port) | |
request = Net::HTTP::Post.new(url) | |
response = http.request(request) | |
if response.code == "200" | |
responseJson = JSON.parse(response.body) | |
if responseJson and responseJson["result"] | |
puts "Number of cars detected: ", responseJson["result"].size | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment