Just a quick note: The array of array thing makes more sense in C++, as most of the functions returned cv::Mat, a 2D array. So the output of HoughLines was a n x 1 array (where n is the number of lines), but the datatype was cv::Vector2f (a struct of two floats). As the Python version is just a wrapper, it still makes sense to return in the same format.
In general, blurring comes before edge detection. The method you used is commutative so it doesn't matter, but a bilateral filter (which preserves edges) is not; and therefore you'd just end up with blurry lines instead of sharp ones.
have you tried preprocessing with a blur filter before the canny edge function? the cv2.BilateralFilter is a good choice because it preserves edges while smoothing out irregularities. It can be a bit cpu intensive though.
Simple improvements to performance could be to only print out every 100'th time and do an average, and maybe only draw the 10 longest lines. (maybe by sorting the list on lines) and I'm sure some way smarter things that you will show me... In the next video that I will watch right now!
I binge watched the entire series in a night. I'm rewatching it. Netflix might as well buy this from you. Also, kindly check your ig handle. I dm'ed you there. Big fan, Sir
What are your graphic settings? Mine isn't detecting as many edges as yours, and I suspect it may be due to some settings to do with anti-aliasing, and I'm worried in the future it may affect the performance of the AI on my end.
You can either mess with the settings in GTA, or just mess with your houghlines/blur functions. The anti-aliasing would only help improve line detection, but blur also does the same thing for our purposes. I was running gta in ultra, but recently put everything to minimum, and didn't notice any differences.
Lines are everywhere on the screen but there are only 2 large spaces without any lines: the road and the sky. Might that be a better way of road detection?
I am doing this with GTA Vice City but I cant see the lines maybe because the lines are not so bright as GTA 5. what would you suggest me to do for that?
My question is, using both visual input and collected user input, could an AI with recursive learning work out how to play games based solely on viewing and understanding or emulating user data for certain situations? Technically, your project puts us half way there?
You still have to give it goals, as in things for it to try to accomplish (via weights on outputs) but yes, there have been projects that have done just that. As I understand it some of Google's DeepMind projects (DOTA gaming) trained this way.
def HoughLines(image, rho, theta, threshold, lines=None, srn=None, stn=None, min_theta=None, max_theta=None) i think the problem is u missed and miss used the "lines=None" parameter :D .. and lol great tutorials, u sometimes do stuff off screen but i like the way u teach us :D ,, THANKS
Hey, I am trying out the same for practice. Can anyone please help me find the location in the game where the video is shot? Coz other locations have a lot of disturbance but the one used in the video seems to be quiet.
I am getting this error can someone help:- Traceback (most recent call last): File "C:/Users/poorn/PycharmProjects/Poornith/Poornith.py", line 27, in new_screen = process_img(screen) File "C:/Users/poorn/PycharmProjects/Poornith/Poornith.py", line 21, in process_img lines = cv2.HoughCircles(processed_img, 1, np.pi/180, 180, 20, 15) cv2.error: OpenCV(4.3.0) C:\projects\opencv-python\opencv\modules\imgproc\src\hough.cpp:2318: error: (-5:Bad argument) Unrecognized method id. Actually only CV_HOUGH_GRADIENT is supported. in function 'cv::HoughCircles'
why not pick out the yellow line in the middle of the road base on color first(so you dont need to deal with trees), useing HSV(or HSB, basicly the same thing with different name) mode should be preferable, idk if cv2 has fuction like RGB2HSV, if it has then fill the yellow pixels(hue around 40, plus minus 10 maybe) with white(or leave it as is) and the rest with black also why not do the crop or region of interest first, should make the rest process much faster
Hi! Great channel! I had the same problem with the line finder where it didn't quite respond to me changing the parameters. I found this stackoverflow thread which seems to solve it: stackoverflow.com/questions/35609719/opencv-houghlinesp-parameters The problem appears to be that the parameters are read differently than in the documentation so call the function with the parameters like so: lines = cv2.HoughLinesP(edges, 1, np.pi/180, threshold=200, minLineLength=20, maxLineGap=5)
anyone noticed he is doing exactly the udacity course on autonomous driving? even the code its the exact same with same function names like draw_lines and process_img
I don't think udacity invented the grayscale > canny > roi > houghlines workflow for lane detection. Would be happy to attribute them if that was the case. A quick google search for how to find lanes with python and open cv seems to suggest this is pretty standard procedure.
Nah, I really doubt we're ...going down the same road... *chuckles to self* I expect the Udacity course took a more serious and realistic approach to self-driving cars. I intend to do no such thing, we're gonna go a bit wild with it. I'm really more interested in the general AI aspect than anything else as well. So far by the end of part 13, I've got a motorcycle that races through traffic, and I've begun testing evading police. I suspect Udacity taught you to stay in between the lines. ;)
"Wow that guy just totally went around me, what a prick!"
*sits on parked scooter in middle of the road*
On topic though: loving this series.
I could have been stopped for a kitten, that driver has no idea!
I laughed out loud
I've loved the way you describe "blur" algorithm! Like a nervous washing board with hands... Really creative one! Bravo.
Man, this thing is going to be my major project .... thanks sentdex you are great
thanks, Edward Snowden
welx
Why arent uyo in Russia?
thank you for the great job ! just started learning python because of this series .. please keep doing these video-game-related things
Just a quick note:
The array of array thing makes more sense in C++, as most of the functions returned cv::Mat, a 2D array. So the output of HoughLines was a n x 1 array (where n is the number of lines), but the datatype was cv::Vector2f (a struct of two floats). As the Python version is just a wrapper, it still makes sense to return in the same format.
In general, blurring comes before edge detection. The method you used is commutative so it doesn't matter, but a bilateral filter (which preserves edges) is not; and therefore you'd just end up with blurry lines instead of sharp ones.
have you tried preprocessing with a blur filter before the canny edge function? the cv2.BilateralFilter is a good choice because it preserves edges while smoothing out irregularities. It can be a bit cpu intensive though.
Damn, made this comment before finishing the video. doh!
hahaha
Simple improvements to performance could be to only print out every 100'th time and do an average, and maybe only draw the 10 longest lines. (maybe by sorting the list on lines) and I'm sure some way smarter things that you will show me... In the next video that I will watch right now!
fuba44 that's actually a pretty good idea..! I like it
I binge watched the entire series in a night. I'm rewatching it. Netflix might as well buy this from you. Also, kindly check your ig handle. I dm'ed you there. Big fan, Sir
Hey Harrison, I don't know if you've done this yet but turning off head bobbing in first person might help things slightly in any number of ways
I wasn't aware we could turn off head bobbing.
how did python recognize line[0] as coordinate that must be lined to another vertice?
and, how did it know coords [1,2,3,4] as x1,y1,x2,y2 ?
If someone gets a NoneType, it means that there are no lines that can be drawn. You will have to put a "if lines is not None:" above the draw_lines
What are your graphic settings? Mine isn't detecting as many edges as yours, and I suspect it may be due to some settings to do with anti-aliasing, and I'm worried in the future it may affect the performance of the AI on my end.
You can either mess with the settings in GTA, or just mess with your houghlines/blur functions. The anti-aliasing would only help improve line detection, but blur also does the same thing for our purposes. I was running gta in ultra, but recently put everything to minimum, and didn't notice any differences.
8:19 how u did that spacing thing, I mean what's the shortcut key for that.
Tab and shift+tab
Lines are everywhere on the screen but there are only 2 large spaces without any lines: the road and the sky. Might that be a better way of road detection?
with the "processed_img = " lines in the "process_img" function, those are just attributes you're giving to the "processed_img" correct?
8:25 fuck me
Instead of try/except, I would do:
if not lines:
hahahhahaha, but my try/except sin felt so good. It should be your way though, no arguing with that.
I said noooo out loud before you said "fight me"
He said bite me ;p
Good ol' On Error Resume Next
i think he said fight me
first time i heard hough the way you say the name hugh. i always heard it pronounced it huff in school.
I'm probably saying it wrong
For some reason im only detecting one thing at a time, am I missing something as to detect multiple lines?
Maybe a subtle difference in code, compare your code to mine: pythonprogramming.net/hough-lines-python-plays-gta-v/
I am doing this with GTA Vice City but I cant see the lines maybe because the lines are not so bright as GTA 5. what would you suggest me to do for that?
My question is, using both visual input and collected user input, could an AI with recursive learning work out how to play games based solely on viewing and understanding or emulating user data for certain situations? Technically, your project puts us half way there?
You still have to give it goals, as in things for it to try to accomplish (via weights on outputs) but yes, there have been projects that have done just that. As I understand it some of Google's DeepMind projects (DOTA gaming) trained this way.
This guy is like God to me.
much respect from Pakistan. 🙌
hello i want to find rotation angle of my image using opencv python can you help me out...!
def HoughLines(image, rho, theta, threshold, lines=None, srn=None, stn=None, min_theta=None, max_theta=None)
i think the problem is u missed and miss used the "lines=None" parameter :D .. and lol great tutorials, u sometimes do stuff off screen but i like the way u teach us :D ,, THANKS
check the answer here : stackoverflow.com/questions/35609719/opencv-houghlinesp-parameters
I keep running into "TypeError: 'NoneType' object is not iterable"
oh i think it just breaks when it stops finding lines
try doing this on top of the for loop in the function: if lines.any() != None:
Hey, I am trying out the same for practice. Can anyone please help me find the location in the game where the video is shot? Coz other locations have a lot of disturbance but the one used in the video seems to be quiet.
Blaine county. Somewhere near Trevor's trailer.
I am getting this error can someone help:-
Traceback (most recent call last):
File "C:/Users/poorn/PycharmProjects/Poornith/Poornith.py", line 27, in
new_screen = process_img(screen)
File "C:/Users/poorn/PycharmProjects/Poornith/Poornith.py", line 21, in process_img
lines = cv2.HoughCircles(processed_img, 1, np.pi/180, 180, 20, 15)
cv2.error: OpenCV(4.3.0) C:\projects\opencv-python\opencv\modules\imgproc\src\hough.cpp:2318: error: (-5:Bad argument) Unrecognized method id. Actually only CV_HOUGH_GRADIENT is supported. in function 'cv::HoughCircles'
hi, I don't think after using Gaussian blurring, the image will look like yours' image. And my experiment just likes what I said.
I think that blur is just used to smoosh the edge wouldn't widen the line.
Probably a boxfilter is enough and faster for this purpose
why not pick out the yellow line in the middle of the road base on color first(so you dont need to deal with trees), useing HSV(or HSB, basicly the same thing with different name) mode should be preferable, idk if cv2 has fuction like RGB2HSV, if it has then fill the yellow pixels(hue around 40, plus minus 10 maybe) with white(or leave it as is) and the rest with black
also why not do the crop or region of interest first, should make the rest process much faster
this is epic
Does anyone know how to find moving circles?
I'd say search google for OpenCV Guitar Hero. There would be a code that might help ya?
Hi! Great channel!
I had the same problem with the line finder where it didn't quite respond to me changing the parameters. I found this stackoverflow thread which seems to solve it:
stackoverflow.com/questions/35609719/opencv-houghlinesp-parameters
The problem appears to be that the parameters are read differently than in the documentation so call the function with the parameters like so:
lines = cv2.HoughLinesP(edges, 1, np.pi/180, threshold=200, minLineLength=20, maxLineGap=5)
This worked Thanks :)
anyone noticed he is doing exactly the udacity course on autonomous driving? even the code its the exact same with same function names like draw_lines and process_img
I don't think udacity invented the grayscale > canny > roi > houghlines workflow for lane detection. Would be happy to attribute them if that was the case. A quick google search for how to find lanes with python and open cv seems to suggest this is pretty standard procedure.
sentdex Damn then i wasted my money there i really like your videos. you are way more entertaining to watch
Nah, I really doubt we're ...going down the same road... *chuckles to self* I expect the Udacity course took a more serious and realistic approach to self-driving cars. I intend to do no such thing, we're gonna go a bit wild with it. I'm really more interested in the general AI aspect than anything else as well. So far by the end of part 13, I've got a motorcycle that races through traffic, and I've begun testing evading police. I suspect Udacity taught you to stay in between the lines. ;)
2:10
It is pronounced like "huff" kinda like tough.
HOW DO I GET MORE THEN 1 FPS ON MY CAPTURE
!?!?!?1 I HAVE GTX 1080 AND 6700 INTEL
Mine's a GTX 1070 with 6700 and works smoothly for me so far. Look at part one of his tutorial. That might help.
you did some blurred lines here
Hey, how can I get your desktop wallpaper?
Really, 3 pixels thick is not very neat.
Hough = pronounces "Huff"
It hurts to watch you do a lot of the processing before the mask.
uncensored videos help us to understand ur thinking process. nice work bro thank you
I play VAPOR WAVE to my BITCOIN investments, Hough Lines of FORTRAN all day & do hacker stuff