Log in

View Full Version : OpenCV Python! Where to start?


tomy
07-05-2016, 11:15
I have openCV installed with python but all the tutorials I am finding expect you to know a bunch of prior knowledge. Anyone have a good spot for a newbie to start. I have no prior knowledge of vision tracking or how it works. Thanks for you help.

Tomy

virtuald
07-05-2016, 12:50
There's a lot to learn about image processing in general. :)

I recommend the OpenCV tutorials/walkthroughs (http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_tutorials.html). Additionally, there are a bunch of examples distributed in the OpenCV source tree (https://github.com/Itseez/opencv/tree/master/samples/python) -- try to run them locally and see what they do, and then modify them in small ways.

Once you've done that, then I recommend reading various FIRST-related image processing whitepapers and related code (search ChiefDelphi for these), to get a feel for what types of techniques you can use to accomplish the tasks you need to accomplish.

You may find that GRIP is a useful tool (I haven't used it, but it looks promising) to experiment with image processing techniques and such. In particular, screensteps has a walkthrough on how to do image processing for the 2016 game using GRIP (https://wpilib.screenstepslive.com/s/4485/m/50711/l/481750-using-grip-for-the-2016-game).

tomy
07-05-2016, 12:53
There's a lot to learn about image processing in general. :)

I recommend the OpenCV tutorials/walkthroughs (http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_tutorials.html). Additionally, there are a bunch of examples distributed in the OpenCV source tree (https://github.com/Itseez/opencv/tree/master/samples/python) -- try to run them locally and see what they do, and then modify them in small ways.

Once you've done that, then I recommend reading various FIRST-related image processing whitepapers and related code (search ChiefDelphi for these), to get a feel for what types of techniques you can use to accomplish the tasks you need to accomplish.

You may find that GRIP is a useful tool (I haven't used it, but it looks promising) to experiment with image processing techniques and such. In particular, screensteps has a walkthrough on how to do image processing for the 2016 game using GRIP (https://wpilib.screenstepslive.com/s/4485/m/50711/l/481750-using-grip-for-the-2016-game).


Thank you. I've poked around with grip would you do the same processes as grip pip line? (Resize -> HSV/HSL -> Find Contours -> Filter Controus -> Pusblish to network table)

What is the difference between HSV and HSL?

virtuald
07-05-2016, 12:56
Thank you. I've poked around with grip would you do the same processes as grip pip line? (Resize -> HSV/HSL -> Find Contours -> Filter Controus -> Pusblish to network table)

Yes, GRIP uses OpenCV underneath the hood, so a lot of the things that you can do with GRIP will easily map to OpenCV operations of some kind -- it just might add some extra magic to make it easier to use.

What is the difference between HSV and HSL?

https://en.wikipedia.org/wiki/HSL_and_HSV

tomy
07-05-2016, 13:04
Yes, GRIP uses OpenCV underneath the hood, so a lot of the things that you can do with GRIP will easily map to OpenCV operations of some kind -- it just might add some extra magic to make it easier to use.



https://en.wikipedia.org/wiki/HSL_and_HSV


Thanks for the in - site. Is the method I described before the best way to do vision tracking with openCV?

-(Resize -> HSV/HSL -> Find Contours -> Filter Controus -> Pusblish to network table)

virtuald
07-05-2016, 13:06
Thanks for the in - site. Is the method I described before the best way to do vision tracking with openCV?

-(Resize -> HSV/HSL -> Find Contours -> Filter Controus -> Pusblish to network table)

Generally speaking, that is the methodology we've used for image processing the last few years.

Arhowk
07-05-2016, 13:08
Here's our OpenCV Python code... The numbers it gave me were always wrong but I think thats just because it wasn't tuned...

https://github.com/1684Chimeras/VEX_1684A/blob/master/2016CompetitionRobot/src/modules/camera.py#L109-L207

note that line 150 doesn't error out but doesn't do anything either for some reason

and lines 126-143 are specific for grabbing an axis camera image

tomy
07-05-2016, 13:10
Do you have any other tips? How to deal with lag or with blurry images? I've heard that has been a problem.

virtuald
07-05-2016, 14:31
Do you have any other tips? How to deal with lag or with blurry images? I've heard that has been a problem.

See this thread (http://www.chiefdelphi.com/forums/showthread.php?t=147568&page=3) (presentation by team 254 at championship conferences).

tomy
08-05-2016, 10:51
Here's our OpenCV Python code... The numbers it gave me were always wrong but I think thats just because it wasn't tuned...

https://github.com/1684Chimeras/VEX_1684A/blob/master/2016CompetitionRobot/src/modules/camera.py#L109-L207

note that line 150 doesn't error out but doesn't do anything either for some reason

and lines 126-143 are specific for grabbing an axis camera image

Are you guys using grip with that code?

Arhowk
09-05-2016, 12:11
Are you guys using grip with that code?

Both. The top section (unhighlighted) is for GRIP. The bottom (highlighted) section uses raw openCV

tomy
09-05-2016, 18:16
Both. The top section (unhighlighted) is for GRIP. The bottom (highlighted) section uses raw openCV

Interesting. Thank you for the code by the way it has helped me a lot. Do you use GRIP and open-CV in tandem??

Arhowk
09-05-2016, 18:53
Interesting. Thank you for the code by the way it has helped me a lot. Do you use GRIP and open-CV in tandem??



We calibrate with the GRIP than transpose those values over to OpenCV. Since the grip is already calibrated, there's a GRIP fallback option in case OpenCV failed

tomy
09-05-2016, 19:27
We calibrate with the GRIP than transpose those values over to OpenCV. Since the grip is already calibrated, there's a GRIP fallback option in case OpenCV failed

I wrote some simple code to calibrate the camera in openCV using Track-bars. Would you like a copy of it? I haven't had time to implement it into working code yet I'm just using it to get the values for HSV and manually putting them into another part of code.

Arhowk
10-05-2016, 08:08
I wrote some simple code to calibrate the camera in openCV using Track-bars. Would you like a copy of it? I haven't had time to implement it into working code yet I'm just using it to get the values for HSV and manually putting them into another part of code.

This was my last year so I doubt I'll be able to make use of it. You can always post it on this sub forum if you think it merits use.

tomy
10-05-2016, 14:45
This was my last year so I doubt I'll be able to make use of it. You can always post it on this sub forum if you think it merits use.

I think I will at some point maybe towards the begging of the season such that we can use it next year.

tomy
10-05-2016, 22:08
Here's our OpenCV Python code... The numbers it gave me were always wrong but I think thats just because it wasn't tuned...

https://github.com/1684Chimeras/VEX_1684A/blob/master/2016CompetitionRobot/src/modules/camera.py#L109-L207

note that line 150 doesn't error out but doesn't do anything either for some reason

and lines 126-143 are specific for grabbing an axis camera image

I just finished up my simple vision tracking and it is sole based off your code. Thank you. Also if you could let me know what you think.

http://pastebin.com/h4kjdz0W

RadhikaTheFish
13-09-2016, 18:48
Thanks,