Python opencv pass matched object coordinates to GPC script

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

Python opencv pass matched object coordinates to GPC script

Postby mslake » Fri Oct 27, 2023 3:24 am

Is it possible to pass matched object X & Y coordinates from the Python opencv script to the GPC script? I have the Python part of the code worked out. I am struggling to find a way to send that data to the GPC script through gvc_read. Any examples or suggestions would be greatly appreciated!
User avatar
mslake
Private First Class
Private First Class
 
Posts: 3
Joined: Mon Oct 16, 2017 8:59 pm

Re: Python opencv pass matched object coordinates to GPC scr

Postby Mad » Fri Oct 27, 2023 10:29 am

Take a look Apex Legends by J2KBr in this misc section. At the top is a GPC example with gcv_read and at the very bottom you'll see the python side gcvdata bytearray.
https://www.consoletuner.com/wiki/index ... 2:gcv_read
Mad
Major General
Major General
 
Posts: 4537
Joined: Wed May 22, 2019 5:39 am

Re: Python opencv pass matched object coordinates to GPC scr

Postby mslake » Sat Oct 28, 2023 5:51 pm

Thank you! My problem was not defining the correct data type in the gvc code. For anyone else with this problem, here is what I did.

Python code, store the coordinates found from opencv:

Code: Select all
import struct
self.gcvdata[0:2] = struct.pack('>H', center_x)
self.gcvdata[2:4] = struct.pack('>H', center_y)
 


GPC code, read the coordinates:

Code: Select all
uint16 center_x;
uint16 center_y;
gcv_read(0, &center_x);
gcv_read(2, &center_y);
User avatar
mslake
Private First Class
Private First Class
 
Posts: 3
Joined: Mon Oct 16, 2017 8:59 pm


Return to Gtuner Computer Vision

Who is online

Users browsing this forum: No registered users and 10 guests