OpenCV decentralized processing for stereo vision - python

I have a decent amount of experience with OpenCV and am currently familiarizing myself with stereo vision. I happen to have two JeVois cameras (don't ask why) and was wondering if it was possible to run some sort of code on each camera to distribute the workload and cut down on processing time. It needs to be so that each camera can do part of the overall process (without needing to talk to each other) and the computer they're connected to receives that information and handles the rest of the work. If this is possible, does anyone have any solutions or tips? Thanks in advance!

To generalize the stereo-vision pipeline (look here for more in-depth):
Find the intrinsic/extrinsic values of each camera (good illustration here)
Solve for the transformation that will rectify your cameras' images (good illustration here)
Capture a pair of images
Transform the images according to Step 2.
Perform stereo-correspondence on that pair of rectified images
If we can assume that your cameras are going to remain perfectly stationary (relative to each other), you'll only need to perform Steps 1 and 2 one time after camera installation.
That leaves you with image capture (duh) and the image rectification as general stereo-vision tasks that can be done without the two cameras communicating.
Additionally, there are some pre-processing techniques (you could try this and this) that have been shown to improve the accuracy of some stereo-correspondence algorithms. These could also be done on each of your image-capture platforms individually.

Related

Detect stitches / seams on the leather from the image. Can it be done just with Python Open CV and built in functions for image manipulation?

I am just starting with computer vision and I do not have much experience with this area. Therefore sorry for little bit generic question but I am not sure how to start and go in the correct direction.
Like in the title. I am building a system which is able to capture the image from the camera and I would like to detect if the 2 lines of stitches / seams are parallel to each other and if the gap between the lines is in specified limits / threshold. See below sample picture:
Can those lines be detected by some functions in open cv or do I need to use machine learning approach and built a model which will recognize the single stitch on the picture and then based on the detection draw new lines and perform calculations?

OpenCV - Best Image Recognition Algorithm

I am working on a "UPS Package Detection" program. The app takes photos of my porch every 1 minute from a Raspberry Pi. I then run a the image through a Feature Matching against a "cube" to detect cubes (packages are cubes, right??)
I decide if a package has been delivered if there are 3 or more observations (see the two images below). I find my algorithm crude, and I know I can do better. Can someone please recommend and advise a better way for me to detect if a package has been delivered.
(I am using Python) Not a package - number of observations very low
a package - number of observations high
No, in your case the packages are not cubes. They are more like a blob.
If you want to detect any package on your porch, not just ups, you can:
A) create a standardized environment for taking the picture (constant illumination, clear background, pattern on the froor, etc). So to say you have to create a package dropping zone that always looks the same to your camera, except when a package is present.
or
B) (the hard way) compare the images over time. I assume, the image we see is taken outside. So there will be different brightness during the day. Shadows. Etc. You can pre process the image accordingly. For example, use a threshold that is calculated as a percentage of the brightest pixel in the image. Then you can compare images over time. If there is a big blob, where was none in the previous images, there might be a package.
or
C) if you only want to detect UPS packages only, you can use OCR or try to match for the UPS logo. This approach will not only detect packages, but also the UPS guy himself :)
However, have fun, it sounds like a really nice home project.

How to change the attributes of cv2.StereoBM_create for depth map in OpenCV Python

I was implementing the depth map construction, code of which (in Python) is available here OpenCv Docs - depthMap I was successful in getting the depth map as they showed in the doc for their given images-pair (left and right stereo images) tsukuba_l.png and tsukuba_2.png. I considered testing my own image pairs, so I took from my mobile a pair of images, as shown below:
When I run the code, I'm getting the depth map something like this
I tried playing with numDisparities and blocksize, but it didn't help in getting the best map.
I thought of checking the script of cv2.StereoBM_create in its master folder in Github, but couldn't get that online. Can you help me with a way to implement depth maps for custom images taken by me? is there a way that we can play with the parameters or at least get me the link to GitHub master module that has all Stereo related modules. Thank you.
I guess you did not rectify the images which is fundamental for stereo matching.
You should first calibrate your stereo system (if you took them with mobile phone every image pair you take will have a different transform, the two cameras need to have always the same transformation between each other) and then rectify the images, in that way they are projected onto the same plane, then the stereo match algorithm looks for correspondences in the other image on the same rows.
Check in the docs for stereoRectify(), you will see some images as example of the rectification process.
By the way there is another python example based on SemiGlboal Block Matching algorithm in opencv/samples/python/stereo_match.py.

Determining the "quality" of a video in Python

I am trying to compute a rough "quality" metric for a video, which takes the following into consideration:
"Smoothness" of video; i.e., the opposite of how "choppy" it is
Image quality; i.e. if there are a lot of compression artifacts, the quality should decrease in size
I came across https://github.com/aizvorski/scikit-video, but the code seems to be littered with FIXMEs and TODOs, and on top of that there's barely any comments or documentation.
Is there a Python library, or even a program with a CLI, for computing video quality, or perhaps a set of libraries that will help me compute the above two metrics separately?
Image Quality
I would think that "Image Quality" is largely a function of bit-depth (or effective bit-depth) and bit-rate.
You can parse ffmpeg output to get this information. PIL or PyQt/PySide can also do this.
Smoothness
For smoothness, you may need to use some type of optical flow algorithm and get deltas from frame to frame.
OpenCV looks like a project that does many of these things.

How can I detect and track people using OpenCV?

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.

Categories