Skip to content

Instantly share code, notes, and snippets.

@prats226
Created July 25, 2017 03:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prats226/af4b28a87fdfe41ce5e4166b64f6617f to your computer and use it in GitHub Desktop.
Save prats226/af4b28a87fdfe41ce5e4166b64f6617f to your computer and use it in GitHub Desktop.
Ruby gist to count number of cars using pretrained model
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