I am trying to track an object and mask or Hide it (a CODE in this case) using OpenCV and Python. As example I am using this video , the code will showing on 1min19s :
https://www.dropbox.com/s/eu01hxoxmd3ns5f/capture-3.mp4?dl=0
What I need is to keep track on the CODE and mask or Hide it as the video without detecting other parts of the video as the code. Tracking by colour doesn't work here.
Any idea for a good approach on this problem?
Tracking is much more complex than searching the similar colour. OpenCV has implemented some tracking algorithms, what you need to do is to use the existing apis to solve the problem. Here is an introduction to OpenCV tracker.
If you do not stick to OpenCV, dlib is also a c++ library with python interface which also implements object tracking algorithms.
Related
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'm trying to implement a python program to remove the background and extract the object/objects in the foreground from any given static image (as shown in the attached images). This is similar to "iPhoneX Portrait Effect" or "Bokeh Effect". However, instead of blurring the background one needs to completely remove it.
In short, I want to extract objects from any given image and also create a mask. Below are the examples of both respectively:
Object Extraction:
Image Mask:
I have somewhere listened to Google's DeepLab, but I don't know how to start with it.
Can someone help me, please!
Any step by step tutorial will be very appreciated.
Thanks in advance!
This is a really hard task, there is a reason there are basically no good software to do this already, even in photoshop this is a struggle. I can advice you to start with open Cv and their implemented facial tracking which you may need to configure to work with animals if thats your goal
resources
facial detection:
https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_objdetect/py_face_detection/py_face_detection.html#face-detection
object detection:
https://docs.opencv.org/2.4/modules/contrib/doc/facerec/facerec_tutorial.html
Firstly you should collect data(image) for which object you want to detect or extract the object/objects in the foreground and also create a mask.
Then using tensorflow you can train an instance segmentation model Using your own dataset. (Ref : instance_segmentation)
After getting mask you can extract the foreground.
I'm trying to get the black region from an image using TensorFlow. To this point I was using OpenCV but it fails to get the hole region given that the gray scale is very complicated.
The image I'm using is a photo of a electric meter, the whole meter is white(normally) except for the part with the numbers that is black. I would want to isolate this part in order to get the numbers later on.
To de the date, I have been using the function findContours from OpenCV, with a defined threshold .
I have seen that TensorFlow is very potent so I think this could no be a problem, but I can't find any documentation. Any hints? Thanks!
Tensorflow is a general purpose math library that is unique in two respects:
It provides automatic differentiation.
It has efficient kernels built to run on either the CPU or GPU.
It does have a library of image functions, but it's nowhere near as extensive as OpenCV, and will never be. Those are mostly for data augmentation (as it pertains to ML) and data loading.
Note that you can run OpenCV code on the GPU in many cases (I'm not sure about findContours in particular. So sticking with OpenCV should be considered.
But within tensorflow you would have to re-write that function yourself. In looking at the code (which I provided a link to in your question) it doesn't look very hard to do. You could replicate that in symbolic tensorflow operations in relatively short order, but nothing like that exists pre-built in tensorflow. Nor is it likely to in the future.
I have a image region labelling programme which was coded with python and library of PyQt4, I want to implement the magic wand function like photoshop and GMIP to selection a region referring a object and then to label the region. Could you tell me how to implement that or Are there some libray which can be used to deal with the issue.
Thank you, I have found that a [blog]: http://www.losingfight.com/blog/2007/08/28/how-to-implement-a-magic-wand-tool/ "blog of Andy Finnel" which includes the detail of implementing such algorithm. I also found that downscaling the image that you will process and then rescale the image up is a good ideal for performance reason.
I have a camera that will be stationary, pointed at an indoors area. People will walk past the camera, within about 5 meters of it. Using OpenCV, I want to detect individuals walking past - my ideal return is an array of detected individuals, with bounding rectangles.
I've looked at several of the built-in samples:
None of the Python samples really apply
The C blob tracking sample looks promising, but doesn't accept live video, which makes testing difficult. It's also the most complicated of the samples, making extracting the relevant knowledge and converting it to the Python API problematic.
The C 'motempl' sample also looks promising, in that it calculates a silhouette from subsequent video frames. Presumably I could then use that to find strongly connected components and extract individual blobs and their bounding boxes - but I'm still left trying to figure out a way to identify blobs found in subsequent frames as the same blob.
Is anyone able to provide guidance or samples for doing this - preferably in Python?
The latest SVN version of OpenCV contains an (undocumented) implementation of HOG-based pedestrian detection. It even comes with a pre-trained detector and a python wrapper. The basic usage is as follows:
from cv import *
storage = CreateMemStorage(0)
img = LoadImage(file) # or read from camera
found = list(HOGDetectMultiScale(img, storage, win_stride=(8,8),
padding=(32,32), scale=1.05, group_threshold=2))
So instead of tracking, you might just run the detector in each frame and use its output directly.
See src/cvaux/cvhog.cpp for the implementation and samples/python/peopledetect.py for a more complete python example (both in the OpenCV sources).
Nick,
What you are looking for is not people detection, but motion detection. If you tell us a lot more about what you are trying to solve/do, we can answer better.
Anyway, there are many ways to do motion detection depending on what you are going to do with the results. Simplest one would be differencing followed by thresholding while a complex one could be proper background modeling -> foreground subtraction -> morphological ops -> connected component analysis, followed by blob analysis if required. Download the opencv code and look in samples directory. You might see what you are looking for. Also, there is an Oreilly book on OCV.
Hope this helps,
Nand
This is clearly a non-trivial task. You'll have to look into scientific publications for inspiration (Google Scholar is your friend here). Here's a paper about human detection and tracking: Human tracking by fast mean shift mode seeking
This is similar to a project we did as part of a Computer Vision course, and I can tell you right now that it is a hard problem to get right.
You could use foreground/background segmentation, find all blobs and then decide that they are a person. The problem is that it will not work very well since people tend to go together, go past each other and so on, so a blob might very well consist of two persons and then you will see that blob splitting and merging as they walk along.
You will need some method of discriminating between multiple persons in one blob. This is not a problem I expect anyone being able to answer in a single SO-post.
My advice is to dive into the available research and see if you can find anything there. The problem is not unsolvavble considering that there exists products which do this: Autoliv has a product to detect pedestrians using an IR-camera on a car, and I have seen other products which deal with counting customers entering and exiting stores.