Why is the gcv_ready() in GPC script always failed?

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

Why is the gcv_ready() in GPC script always failed?

Postby johnsonwhl » Tue May 16, 2023 1:01 am

Gtuner configuration:python 3.8, opencv 4.2.0.34 following the guide:https://www.consoletuner.com/forum/viewtopic.php?t=15147

The problem is when running python cv script normally in cv windows, gcv_ready() in GPC script always failed and info "something wrong" poping up in Gtuner output panel.

I'm confused badly, Why? Could anybody help? Thanks......


Code: Select all
 
int8 gamepadLstick_x = 0;
int8 gamepadLstick_y = 0;
 
main {
    if(gcv_ready()) {
        gamepadLstick_x = gcv_read(0);
        gamepadLstick_y = gcv_read(1);
        printf("test");
        }
    else printf("something wrong");
    }


Code: Select all
 
import os
import cv2
 
class GCVWorker:
    def __init__(self, width, height):
        os.chdir(os.path.dirname(__file__))
        self.gcvdata = bytearray([0x00,0x00])
        print("__init__")
        print(self.gcvdata)
 
    def __del__(self):
        print("__del__")
        print(self.gcvdata)
        del self.gcvdata
 
    def process(self, frame):
        self.gcvdata[0] = 100
        self.gcvdata[1] = 100
        print("process")
        print(self.gcvdata)
        return frame,self.gcvdata
 
Attachments
Gtuner cfg.PNG
Gtuner configuration
Gtuner cfg.PNG (86.13 KiB) Viewed 1980 times
User avatar
johnsonwhl
Private First Class
Private First Class
 
Posts: 2
Joined: Tue May 16, 2023 12:44 am

Re: Why is the gcv_ready() in GPC script always failed?

Postby Mad » Tue May 16, 2023 9:58 pm

gcv_ready() is every frame when data is sent. So it'll spam both test and something wrong.

First get rid of the output panel spam;
Code: Select all
import os
import cv2
 
class GCVWorker:
    def __init__(self, width, height):
        os.chdir(os.path.dirname(__file__))
        self.gcvdata = bytearray([0x00,0x00])
 
    def __del__(self):
        del self.gcvdata
 
    def process(self, frame):
        self.gcvdata[0] = 100
        self.gcvdata[1] = 100
        return frame, self.gcvdata

Then change the GPC to print the value of your variables instead when you press the right trigger;
Code: Select all
bool gamepadLstick_x;
bool gamepadLstick_y;
 
main {
    if(gcv_ready()) {
        gamepadLstick_x = gcv_read(0);
        gamepadLstick_y = gcv_read(1);
    }
 
    if(event_active(BUTTON_5)) {
        printf("gamepadLstick_x: %d gamepadLstick_y: %d", gamepadLstick_x, gamepadLstick_y);
    }
}

For the sticks though you want to use fix32. So in the python script you'd use gcvdata.extend and extend to 4 bytes and then adjust the gpc accordingly. I recommend checking out the apex script by J2Kbr and scrolling down to the gcvdata section near the end to see how it's done.
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord
Mad
Major General
Major General
 
Posts: 4537
Joined: Wed May 22, 2019 5:39 am

Re: Why is the gcv_ready() in GPC script always failed?

Postby johnsonwhl » Wed May 17, 2023 3:08 am

Thanks a lot! :smile0517: :smile0517:

It worked! :smile0203:
User avatar
johnsonwhl
Private First Class
Private First Class
 
Posts: 2
Joined: Tue May 16, 2023 12:44 am


Return to Gtuner Computer Vision

Who is online

Users browsing this forum: No registered users and 19 guests