Page 1 of 1

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

PostPosted: Tue May 16, 2023 1:01 am
by johnsonwhl
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
 

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

PostPosted: Tue May 16, 2023 9:58 pm
by Mad
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.

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

PostPosted: Wed May 17, 2023 3:08 am
by johnsonwhl
Thanks a lot! :smile0517: :smile0517:

It worked! :smile0203: