Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
computer_science:computer_vision:opencv:object_identification_tensorflow_opencv_imageai_yolo [2020/08/07 12:46] – carlossousa | computer_science:computer_vision:opencv:object_identification_tensorflow_opencv_imageai_yolo [2023/12/01 12:07] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Object | + | ====== Object |
- | ===== | + | ===== Requirements: |
+ | Be sure to have the [[: | ||
+ | |||
+ | ===== Project Start - Importing Libraries and Testing ===== | ||
+ | |||
+ | ==== Initialize the libraries ==== | ||
+ | |||
+ | <code python> | ||
+ | import cv2 as cv #Loads ComputerVision / OpenCV | ||
+ | from imageai.Detection import ObjectDetection as od # Loads ImageAI | ||
+ | |||
+ | import numpy as np # Imports NumPY | ||
+ | import requests as req # Imports Requests | ||
+ | import os as os # Imports OS Module | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | ==== Testing if OpenCV is working: ==== | ||
+ | |||
+ | <code python> | ||
+ | url = ' | ||
+ | r = req.get(url) # Pass the URL as a Request.Get | ||
+ | with open(' | ||
+ | outfile.write(r.content) | ||
+ | img = cv.imread(' | ||
+ | window_name = ' | ||
+ | cv.imshow(window_name, | ||
+ | cv.waitKey(0) # Wait for any Key to be pressed | ||
+ | cv.destroyAllWindows() # Destroy (all) previous created Windows | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | ==== Preparing for the upcoming project: ==== | ||
+ | |||
+ | Now that we tested that OpenCV is working let's edit that last piece of code, change it to a function, so we can reutilize it often. The complete code until now should look like this: | ||
+ | |||
+ | <code python> | ||
+ | import cv2 as cv | ||
+ | from imageai.Detection import ObjectDetection as od | ||
+ | |||
+ | import numpy as np | ||
+ | import requests as req | ||
+ | import os as os | ||
+ | |||
+ | def showImage(img): | ||
+ | window_name = ' | ||
+ | cv.imshow(window_name, | ||
+ | cv.waitKey(0) | ||
+ | cv.destroyAllWindows() | ||
+ | |||
+ | |||
+ | </ | ||
===== ===== | ===== ===== | ||
- | ===== References: ===== | + | ===== Downloading Images to train the ML ===== |
+ | |||
+ | Run this [[: | ||
+ | |||
+ | ===== External | ||
[[https:// | [[https:// | ||