Self Driving Algorithm - opencv

I'm currently trying to make a self-driving car algorithm that will work with a racing game using open cv and lane detection.
My current algorithm is to take the difference between the the x-component of the lanes to the centre (a certain y distance away from the car) and to adjust the direction based on the difference. This works well with oval tracks. However, it's really unstable with sharp turns.
Does anyone have any suggestions of a better way to implement a self-driving algorithm?
Thanks

Related

Detecting/ tracking the ball in a tennis match video

What algorithm should I use for detecting/tracking a tennis ball in a video of a tennis match? I was thinking of training a custom YOLOv3 model but since I am dealing with a small and fast moving object I think it wouldn't make sense.
You can also use opencv circle detection algorithm (Hough circles) but it requires a bit to tweaking. At least testing it on your test set should be quite straighforward.
See here for an introduction:
https://www.pyimagesearch.com/2014/07/21/detecting-circles-images-using-opencv-hough-circles/
Provided you know in advance the balls colors you could also do color based segmentation, blobs detection and circularity estimation on found objects. This is the cheapest way (in terms of processing complexity) but again nothing beats trying.
Try it, it may work. I detected cars less than 100 pixels using YOLOv3.

reinforcement learning mini-golf game

I'm trying to use a reinforcement learning algorithm to play a simple mini-golf game.
I want to give inputs(angle and force) to a game engine.
Get the final position of the ball.
Based on the final position calculate reward.
Iterate process until success.
I think I can achieve this by using the greedy approach or function approximation. I want to know whether this is possible and want to find a similar example.
In literature, reinforcement learning is the closest thing to artificial general intelligence, so yes, you can apply it to this mini golf game.
The following will be the layout:
States: Location of ball on the field (x, y, z)
Actions: Angle, Force
Rewards: Distance of ball from hole
Depending on how big your field is, this problem should be easily solvable.
I think I can achieve this by using the greedy approach or function approximation.
You would definitely want to use at least a e-greedy approach to promote exploration in earlier episodes.
To simplify the problem, I would consider just a 2D, or maybe even a 1D case first so you get familiar with the algorithm.
For the 1D case, your state would be where along the line your ball is. Your action is the amount of force applied to the ball. And the reward can be based off of how far your ball is from the goal post.
I can code this environment for you if you'd like.

Eye distance relative to shoulder

I am looking for a method to determine the distance between the eyes and top of the shoulder of a person in an image. At first I tried to use haar cascade in opencv to detect the eye position, which worked fine. However, I couldn't find any way to detect the shoulders. I think that it will be a lot of work to come up with my own training sets for my own shoulder detection model, so I am wondering if there is any easier way to do this.
If you can afford enough computing power, OpenPose is a good solution. A simpler approach is described here, I have tried it and it works ok.
You can get a rough estimate of the shoulder width given the eye location using the following rules (used by artists):
Width of the head is twice the distance between the eyes.
Eyes are located halfway between the top of the head and the tip of the chin
This diagram can help you to estimate the distance between the chin tip and the shoulders.

How align(register) and merge point clouds to get full 3d model?

I want to get 3d model of some real word object.
I have two web cams and using openCV and SBM for stereo correspondence I get point cloud of the scene, and filtering through z I can get point cloud only of object.
I know that ICP is good for this purprose, but it needs point clouds to be initally good aligned, so it is combined with SAC to achieve better results.
But my SAC fitness score it too big smth like 70 or 40, also ICP doesn't give good results.
My questions are:
Is it ok for ICP if I just rotate the object infront of cameras for obtaining point clouds? What angle of rotation must be to achieve good results? Or maybe there are better way of taking pictures of the object for getting 3d model? Is it ok if my point clouds will have some holes? What is maximal acceptable fitness score of SAC for good ICP, and what is maximal fitness score of good ICP?
Example of my point cloud files:
https://drive.google.com/file/d/0B1VdSoFbwNShcmo4ZUhPWjZHWG8/view?usp=sharing
My advice and experience is that you already have rgb images or grey. ICP is an good application for optimising the point cloud, but has some troubles aligning them.
First start with rgb odometry (through feature points aligning the point cloud (rotated from each other)) then use and learn how ICP works with the already mentioned point cloud library. Let rgb features giving you a prediction and then use ICP to optimize that when possible.
When this application works think about good fitness score calculation. If that all works use the trunk version of ICP and optimize the parameter. After this all been done You have code that is not only fast, but also with the a low error of going wrong.
The following post is explain what went wrong.
Using ICP, we refine this transformation using only geometric information. However, here ICP decreases the precision. What happens is that ICP tries to match as many corresponding points as it can. Here the background behind the screen has more points that the screen itself on the two scans. ICP will then align the clouds to maximize the correspondences on the background. The screen is then misaligned
https://github.com/introlab/rtabmap/wiki/ICP

Obstacle avoidance with stereo vision

I'm working on a stereo-camera based obstacle avoidance system for a mobile robot. It'll be used indoors, so I'm working off the assumption that the ground plane is flat. We also get to design our own environment, so I can avoid specific types of obstacle that generate false positives or negatives.
I've already found plenty of resources for calibrating the cameras and getting the images lined up, as well as information on generating a disparity map/depth map. What I'm struggling with is techniques for detecting obstacles from this. A technique that instead worked by detecting the ground plane would be just as useful.
I'm working with openCV, and using the book Learning OpenCV as a reference.
Thanks, all
From the literature I've read, there are three main approaches:
Ground plane approaches determine the ground plane from the stereo data and assume that all points that are not on the plane are obstacles. If you assume that the ground is the dominant plane in the image, then you may be able to find it simply a plane to the reconstructed point cloud using a robust model-fitting algorithm (such as RANSAC).
Disparity map approaches skip converting the stereo output to a point cloud. The most popular algorithms I've seen are called v-disparity and uv-disparity. Both look for the same attributes in the disparity map, but uv-disparity can detect some types of obstacles that v-disparity alone cannot.
Point cloud approaches project the disparity map into a three-dimensional point cloud and process those points. One example is "inverted cone algorithm" that uses a minimum obstacle height, maximum obstacle height, and maximum ground inclination to detect obstacles on arbitrary, non-flat, terrain.
Of these three approaches, detecting the ground-plane is the simplest and least reliable. If your environment has sparse obstacles and a textured ground, it should be sufficient. I don't have much experience with disparity-map approaches, but the results look very promising. Finally, the Manduchi algorithm works extremely well under the widest range of conditions, including on uneven terrain. Unfortunately, it is very difficult to implement and is extremely computationally expensive.
References:
v-Disparity: Labayrade, R. and Aubert, D. and Tarel, J.P.
Real time obstacle detection in stereovision on non flat road geometry through v-disparity representation
uv-Disparity: Hu, Z. and Uchimura, K.
UV-disparity: an efficient algorithm for stereovision based scene analysis
Inverted Cone Algorithm: Manduchi, R. and Castano, A. and Talukder, A. and Matthies, L.
Obstacle detection and terrain classification for autonomous off-road navigation
There are a few papers on ground-plane obstacle detection algorithms, but I don't know of a good one off the top of my head. If you just need a starting point, you can read about my implementation for a recent project in Section 4.2.3 and Section 4.3.4 of this design report. There was not enough space to discuss the full implementation, but it does address some of the problems you might encounter.

Resources