This document provides an overview of computer vision and how to get started with computer vision using OpenCV. It discusses how computer vision works using matrix math and deep learning models. It then provides step-by-step instructions on loading and processing images using OpenCV in Python. Finally, it briefly introduces several popular computer vision APIs, including TensorFlow, Google Vision API, Microsoft Computer Vision, Amazon Rekognition, and shows examples of tasks like image classification and object detection using these APIs.
10. OpenCV
Step zero is to install OpenCV
and python
• OpenCV no walk in the park
• Resources at the end of my slides
11. OpenCV
Step one is to start with your
image source
import cv2
image =
cv2.imread(“nebraska_small.jpg")
12. OpenCV
Step two is to convert to
greyscale for most libraries /
functions
import cv2
image =
cv2.imread(“nebraska_small.jpg”, 0)
13. OpenCV
Step three is to use OpenCV
to process your image
import cv2
image = cv2.imread(“nebraska_small.jpg”, 0)
ret, thresh1 = cv2.threshold(image, 127, 255,
cv2.THRESH_BINARY)
ret, thresh2 = cv2.threshold(image, 127, 255,
cv2.THRESH_BINARY_INV)
ret, thresh3 = cv2.threshold(image, 127, 255,
cv2.THRESH_TRUNC)
ret, thresh4 = cv2.threshold(image, 127, 255,
cv2.THRESH_TOZERO)
Binary Binary Inverse
Trunc To Zero
14. OpenCV
Step four is to use AI and ML
to create powerful projects!
•TensorFlow + Inception
•Google Vision API
•Microsoft Azure Computer
Vision
•Amazon Rekognition API
•…OpenCV
15. OpenCV
Easier to use in mobile
• iOS - pod ‘OpenCV'
• Android - OpenCV4Android SDK
• Natural fit with built in camera
32. OCR
THE GREATER KANSAS CITY RESTAURANT ASSOCIAT!ON The Greater
Cit' Restaurant • in 1916. when three Visionary My row, C e
orge Fowler. and Guy Taylor began meeting the baseme#i Of
Myron Green" Cafeteria on this at Walnut. 'g17ö . 'the;
asuocIat20n organized a boycott to combat the rtslnq-
co$t„ eggs from Suppliers Charging unfair prices. effect* -
attention and 1919 the group launched ASSOC i •tiOn CNR A).
The NRA headquarters remained tn Kansas City until 1927 yhen
moved to Chicago. and eventually to Washington. D.C. Today.
the NRA supports the foodservice Industry, which consists of
13.1 employees (10% of the U.S. workforce) generates $660.5
billion in annual sales of the U.S. gross domestic product),
The GKCRA remains One of the strongest chapters of the NRA.
serving the needs of the area's hospitality industry tn parts
of Missouri and Kansas. Focused education and community
support. each year the GKCRA invests thoussnds of dollars into
hospitality scholarships for area youth, Wen as continuing the
education gf alt hospitality employees. Also dedicated to the
financial wen- being or Keans City end the promotion Of
businesses in our reglon, the CKCRA joined the city's effort
to initiate convention and tourism funding in 1974. Original
construction and continued maintenance of Bartle Hall end
other taurtsm and neighborhood development project' ere fUnded
by patrons Of the restaurant and hotel Industries. 2016 marks
the centennial anniversary of the Greater Kansas City
Restaurant Association. 1214 T KE SONS of KANSAS
• Not quiet as good as Google
• JSON structure is a PAIN
33. using System;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
namespace CSHttpClientSample
{
static class Program
{
static void Main()
{
MakeAnalysisRequest("/Users/me/Desktop/nebraska_small.jpg");
Console.WriteLine("nnnHit ENTER to exit...");
Console.ReadLine();
}
static byte[] GetImageAsByteArray(string imageFilePath)
{
FileStream fileStream = new FileStream(imageFilePath, FileMode.Open, FileAccess.Read);
BinaryReader binaryReader = new BinaryReader(fileStream);
return binaryReader.ReadBytes((int)fileStream.Length);
}
static async void MakeAnalysisRequest(string imageFilePath)
{
var client = new HttpClient();
// Request headers - replace this example key with your valid subscription key.
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "key");
// Request parameters. A third optional parameter is "details".
string requestParameters = "visualFeatures=Categories&language=en&details=Landmarks";
string uri = "https://westus.api.cognitive.microsoft.com/vision/v1.0/analyze?" + requestParameters;
Console.WriteLine(uri);
HttpResponseMessage response;
// Request body. Try this sample with a locally stored JPEG image.
byte[] byteData = GetImageAsByteArray(imageFilePath);
using (var content = new ByteArrayContent(byteData))
{
// This example uses content type "application/octet-stream".
// The other content types you can use are "application/json" and "multipart/form-data".
content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
response = await client.PostAsync(uri, content);
string responseBody = await response.Content.ReadAsStringAsync();
Console.Write(responseBody);
}
}
}
}