I'm working on a real-time object detector with tensorflow and opencv.
I've used different SSD and Faster-RCNN based frozen inference graphs and they almost never fail.
The video stream comes from a IR camera fixed to a wall that has a background that almost never changes. There are some misdetections at particular hours of the day (e.g. when the light changes in the afternoon) that occur in the background area or on small objects too close to the camera.
So to fix this little mistakes i wanted to finetune the model with images from the same background.
Being the background always the same, how do i approach the retraining of the model having 1000 misdetections pics that are all almost the same?
In case of variations in the background lighting, it might be possible to use Background Subtraction
https://docs.opencv.org/3.4.1/d1/dc5/tutorial_background_subtraction.html
,while dynmically updating it as shown here:
https://www.pyimagesearch.com/2015/06/01/home-surveillance-and-motion-detection-with-the-raspberry-pi-python-and-opencv/
Thank you.
Related
I'm working on a project and I need to identify the number of grains in pictures with several of these grains touching, overlapping. Can someone help me with this ? Thanks a lot
Train a model of object detection: You can train some model like object detection (YOLOv5) or some other and calculate the count.
This is a very broad question so I will give you a broad answer, you could train a computer vision model, or you could use simple image processing using open cv:
Learn about color threshholding: everything that is not the color of the grain becomes a black pixel, everything else becomes a white pixel.
Learn about MorphologyEx, to disconnect connected grains.
Get the numbers of contours of white objects in the blacked out image.
All of those are simple google searches that will achieve what you desire. Using open CV.
I'm trying to learn computer vision and more specifically open-cv in python.
I want to make a program that would track my barbell in a video and show me its path. (I know apps like this exists but I want to make it myself). I tried using the Canny edge detection and the HoughCircles functions but I seem to get everything but a good result.
I have been using this code to find the edges of my image:
gray = cv.cvtColor(src=img, code=cv.COLOR_BGR2GRAY)
blur = cv.blur(gray, (2,2))
canny = cv.Canny(blur, 60, 60)
And then this code to find the circle:
circles = cv.HoughCircles(canny, cv.HOUGH_GRADIENT, dp=2, minDist=1000, circles=None,maxRadius=50)
This is the result:
Result
left = original image with detected circle // right = canny image
Is this the right way to go or should I use another method?
Train the YOLO model for the barbell to detect barbel object is better than anything you tried with OpenCV. You need at least 500 images. Those images can be found on the internet easily. This tutorial is kick start tutorial on YOLO. Let's give a try.
If you tweak the parameters of HoughCircles it may recognize the barbell [EDIT: but with more preprocessing, gamma correction, blurring etc., so better not], however OpenCV has many algorithms for such object tracking - only a region from the image has to be specified first (if that's OK).
In your case the object is always visible and is not changing much, so I guess many of the available algorithms would work fine.
OpenCV has a built-in function for selection:
initBB = cv2.selectROI("Frame", frame, fromCenter=False, showCrosshair=True)
See this tutorial for tracking: https://www.pyimagesearch.com/2018/07/30/opencv-object-tracking/
The summary from the author suggestion is:
CSRT Tracker: Discriminative Correlation Filter (with Channel and Spatial Reliability). Tends to be more accurate than KCF but slightly slower. (minimum OpenCV 3.4.2)
Use CSRT when you need higher object tracking accuracy and can tolerate slower FPS throughput
I guess accuracy is what you want, if it is for offline usage.
Can you share a sample video?
What's your problem exactly? Why do you track the barbell? Do you need semantic segmentation or normal detection? These are important questions. Canny is a very basic approach It' needs a very stable background to use it. That's why there is deep learning to handle that kind of problem If we need to talk about deep learning you can use MaskRCNN, yolvoV4, etc. there are many available solutions out there.
I started studying machine learning in python a few days ago and I was trying some examples online when I decided to try it for myself using a custom dataset.
However, I noticed that most datasets involve images that are taken from camera photos composing of hundreds, if not thousands of images with the same target image.
If I create a custom icon in Photoshop, do I need to take a picture of my monitor a thousand times to achieve this? Is it possible to train an AI using only a single PNG file?
My goal right now is to let the AI do object detection on another big image and it needs to find the custom icon inside the image, kind of like Finding Waldo. All of which are digital images straight from Photoshop though, so I don`t know if it is possible.
Right now, I am using a python-based Computer Vision library called ImageAI.
You can use a data preparation strategy called Data Augmentation.
There are mainly two types of Augmentation
Linear Transformation
Affine Transformation
Here is a good white paper
http://cs231n.stanford.edu/reports/2017/pdfs/300.pdf
I want to make a drone that can detect objects from up. I found examples
of Background Subtraction but it detects things and then considers new image as background object. I want the drone to come to it's way point and see if something new is detected.
Drone will fly by itself and the image processing will be done using Opencv on Raspberry pi. How do I write the code in python for this? I can code in python. Please tell me what should I follow.
Thanks in advance.
Background subtraction don't works on drones, a stabilized camera don't help. It need to search a homography matrix between frames with subpixel quality and create custom background subtraction algorithm. This work is not work Raspberry and Python.
If you know anything about objects then try to use neural networks for detection. MobileNet v3 can work on Raspberry.
For training do you can use datasets:
http://aiskyeye.com/
https://gdo152.llnl.gov/cowc/
http://cvgl.stanford.edu/projects/uav_data/
https://github.com/gjy3035/Awesome-Crowd-Counting#datasets
I tried writing the code but was not able to do both detections simultaneously
Using HAAR cascades to train for the shape. But will be limited due to orientations etc. Tensorflow can be used. However, detection by color and shape will be a bigger problem.