Can this be done? ( Not request. )

GCV scripting for Gtuner IV and Titan Two. Configuration, examples, questions.

Can this be done? ( Not request. )

Postby Googleforloss » Sat Jan 02, 2021 1:23 am

Hello all,

This is more of a question, not necessarily a request as I know how time consuming openCV/ python scripts can be as i've been doing a far bit of research into the area. But i've been thinking of a way to use openCV with the game nba 2k21 on the next generation systems, and I think i've figured out a system as to which I would want to use it, as it seems practical. But I'm wondering if the openCV system will be fast enough or will I need to use something like CUDA acceleration, as my GPU is only a 1070 nvidia card to maybe increase the speed of which things get done? I could be wrong in what i'm saying and please do correct me, but I have seen some posts on the application of the openCV system in real time with anti-recoil compensation and it's not "quick" enough as some have iterated, so with that being said moving on... In the game nba 2k there is an online delay with the functionality of the meter appearing, give or take 30MS---> on top of the 600ms the window appears for the timing/aiming of the shot. Now, with the old generation this was easily done by one of two ways, either by aiming, or using a FFB activation to "perfect" release. Now the 2k developers combated this by one of three ways, first was removing FFB when the " Button_17 " button, the button used to receive a "perfect" release is pressed down, it searched for the FFB and then released according.. Secondly they made it so the aim point, the point of which you have to swing the right stick Stick_1_x, to random points, ever so slightly. Thirdly, they made it so when holding the "button_17" down depending on where you are on the court it changes the MS of the shot ever so slightly, but with online delay you can't just put in the MS for these specific locations and get the desired results. With this being said although, some have found a way via GPC scripting to get close to getting a " center " on maybe 3/10 shots. with a mix of user input for the timing of the shot. as it is a two way shooting system with using the aim system -- Timing/ Aiming. now that I've gotten everyone caught up with the mechanics, I will get to my Idea. and i'll start with this image.

Image

My Idea is with the slight variances the Orange rectangle appears within the meter, and how the meter always appears above the said players head. that with open CV it can track that center point of the orange rectangle and slide to that specific stick_1_x axis, now in the image I put about 6 rectangles for the openCV to hypothetically recognize, but one can simplify it as a rough draft I would assume, and put make those 6 boxes smaller and move them to half of the meter, as the rate of the right stick being pulled down " stick_1_y" affects where the orange rectangle appears---->Slow - left, medium - middle, fast - right, now of course even with isolating in such a way with the rate of stick_1_y it still has slight variances to the exact point of where stick_1_x needs to be settled, often by <2-10 degrees. with that being said, I was thinking if the orange rectangle appears in said box in the OpenCV program, have it hit stick_1_x to a certain degree or angle. I understand with python and probably needing to put multiple boxes and how time consuming it, maybe even a hundred within in the meter, my simple question to anyone who has an understanding of the python/ openCV program, is if what I am proposing can be done, what are the difficulties, and for someone just starting out, what are some good tutorials to read that will help me on my path of what I want to achieve. Once I have finished my basic tutorials that is, thank you for reading!
User avatar
Googleforloss
Sergeant
Sergeant
 
Posts: 6
Joined: Thu May 28, 2020 4:03 pm

Re: Can this be done? ( Not request. )

Postby J2Kbr » Sat Jan 02, 2021 11:38 am

What you are describing can be implemented with Computer Vision.

However, the issue I see here is the capture card latency. For example, my capture card lags around 140ms behind the monitor I use to play. For real time CV analysis and reaction, 140ms delay may not be acceptable.

I never tested, but using Display Capture with console remote play the latency should be smaller.
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: Can this be done? ( Not request. )

Postby Googleforloss » Tue Jan 05, 2021 4:55 am

Thank you so much J2kBr for the reply, I apologize for my late reply as my internet hasnt been the most consistent the past few days. I had no idea the capture card latency is about 140ms, is that even with the fastest capture card response method? PCI I believe or so they say. or whatever version it is, my mind is a bit hazy at the exact letting of it haha. I believe 140ms would actually be able to get the job done as the entire shot is about 700 MS more or less online. with about 100 ms delay for the meter probably to pop up from when Button_17 is pressed. I wonder what you could get it down to with Remote play functionality, that is of course... when it actually works lol. for Next generation console on the xbox side it is actually bugged and does not work, can confirm from multiple friends and people from discord I believe"ME." confirmed with me as well.
User avatar
Googleforloss
Sergeant
Sergeant
 
Posts: 6
Joined: Thu May 28, 2020 4:03 pm

Re: Can this be done? ( Not request. )

Postby osori » Wed Jan 13, 2021 6:07 pm

I implemented this for 2k next gen about a month ago using a simple method (took me roughly 3 hours in total from scratch) and here are some tips:

- use template matching to find the green triangle.
- once the green triangle is found, draw two diagonal lines going down from the bottommost pixel of the green triangle.
- create a linear array from those two lines, search for an interval that consists of just black-ish pixels surrounded by white-ish pixels (I recommend choosing white as the color from game options)
- now measure the x-coord differrence between the green triangle and the black interval you found, adjust the angle accordingly (use the set_polar function posted somewhere on the forums. For me on 1080p screen, roughly changing the degree by 59/80 of the x-coord difference worked well) and then press L2 (insert humanizer in between).
- I center pretty much 99% percent of the shots this way. Even using the Curry on quickest, I still have to adjust the timing so that I don't do it too fast. You can also make it so it reads the position of your player and adjust the L2 timing based off of that. Tedious since trying to expolate the 3-pt line as a curve was annoying, but not too hard.
- Once all implemented, with no badge and 90 3pt player I shoot 70% from the arc on HOF mycareer.
User avatar
osori
Corporal
Corporal
 
Posts: 4
Joined: Sun Dec 06, 2020 4:51 am

Re: Can this be done? ( Not request. )

Postby J2Kbr » Thu Jan 14, 2021 10:48 am

Thank you osori for your input here. Truly appreciated.
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: Can this be done? ( Not request. )

Postby Googleforloss » Sat Jan 23, 2021 7:16 am

Alright thank you so much for your input, as I am a complete noob to python I will take every step 1 month at a time haha.
User avatar
Googleforloss
Sergeant
Sergeant
 
Posts: 6
Joined: Thu May 28, 2020 4:03 pm

Re: Can this be done? ( Not request. )

Postby eom85 » Sat May 22, 2021 7:21 am

osori wrote:I implemented this for 2k next gen about a month ago using a simple method (took me roughly 3 hours in total from scratch) and here are some tips:

- use template matching to find the green triangle.
- once the green triangle is found, draw two diagonal lines going down from the bottommost pixel of the green triangle.
- create a linear array from those two lines, search for an interval that consists of just black-ish pixels surrounded by white-ish pixels (I recommend choosing white as the color from game options)
- now measure the x-coord differrence between the green triangle and the black interval you found, adjust the angle accordingly (use the set_polar function posted somewhere on the forums. For me on 1080p screen, roughly changing the degree by 59/80 of the x-coord difference worked well) and then press L2 (insert humanizer in between).
- I center pretty much 99% percent of the shots this way. Even using the Curry on quickest, I still have to adjust the timing so that I don't do it too fast. You can also make it so it reads the position of your player and adjust the L2 timing based off of that. Tedious since trying to expolate the 3-pt line as a curve was annoying, but not too hard.
- Once all implemented, with no badge and 90 3pt player I shoot 70% from the arc on HOF mycareer.


Thanks a lot for your input man. This really provided some good starting points for my own development. I implemented it a little different, but the centering works 95% of the time. What I’m struggling with, is timing. I have a bunch of ideas, but nothing seams to be really robust:
Identifying through green arrow pixel position gets inaccurate due to camera movement.
I tried capturing the upwards motion of the meter, but it’s resolution was too low to derive any mathematical curve that could indicate its highest point to release.
You are suggesting to extrapolate the line, but I couldn’t think of a proper way to implement this? Is there bresenham for curved slopes? Do you collect player position from your name tag?

Any hep would be greatly appreciated!!
User avatar
eom85
First Sergeant
First Sergeant
 
Posts: 65
Joined: Wed Jun 21, 2017 7:51 pm


Return to Gtuner Computer Vision

Who is online

Users browsing this forum: No registered users and 56 guests