Gtuner IV 1.07 PUBLIC RELEASE: Computer Vision

Official news and announcements from the ConsoleTuner team.

Re: Gtuner IV 1.07 PUBLIC RELEASE: Computer Vision

Postby PaulaTheKoala » Wed Apr 01, 2020 5:40 pm

The blank/black screen issue seems to happen whenever you try to capture a window that renders in a special way.
I'm currently facing the exact same problem when trying to capture a window that uses OpenGL for rendering.

A workaround would be to disable desktop composition but unfortunately this doesn't appear to be possible with Windows 10 as Microsoft has completely removed the option due to the Desktop/UI now heavily relying on it. There's still some ways of achieving this, but If you've updated Windows recently then this probably won't work for you or it'll cause system instability which could eventually lead to a crash.

Another option would be to create an application that uses the GDI+ Library to capture the target window then render it inside a new window and use that new window as the capture target, but when I tested this on my crap PC I was having performance issues and a white flicker from time to time.
(Though that might of been an issue with my implementation, still experimenting with it lol)

EDIT:

Here's a solution that I whipped up in AutoHotkey.
This requires AutoHotkey (Duh) and the Gdip_All.AHK helper library. (Download it & place it in same folder)

WinCap.ahk:
Code: Select all
#NoEnv
#SingleInstance, Force
#Include, Gdip_All.AHK

CaptureText := ""
CaptureMargin := [ 0, -32, 0, 0 ]

if (!CaptureText)
{
    WinGet WindowList, List
    WinList := []

    Loop, % WindowList
    {
        WindowHandle := WindowList%A_Index%
        WinGet, WindowStyle, Style, % "ahk_id" WindowHandle
       
        if (WindowStyle & 0x10000000) ; WS_VISIBLE
        {
            WinGetTitle, WinTitle, % "ahk_id" WindowHandle
           
            if (StrLen(WinTitle) > 0)
            {
                if (StrLen(WinList) > 1)
                {
                    WinList := WinList "`n"
                }
               
                WinList := WinList WinTitle
            }
        }
    }
   
    VarSetCapacity(CaptureHandle, 0)
   
    Gui +Delimiter`n
    Gui, Add, DropDownList, vCaptureText w330 gCaptureSelection, % WinList
    Gui, Show, w350 h35, % "Select Window"
}

while (!CaptureHandle)
{
    WinGet, CaptureHandle, , % CaptureText
    Sleep, 10
}

Token := Gdip_Startup()
WinGetPos,,, Width, Height, % "ahk_id" CaptureHandle

Gui, New, +Resize hWndGuiHandle
Gui, Add, Picture, % "x0 y0 w0 h0 0xE hWndGuiPictureHandle"
Gui, Show, % "w" (Width + CaptureMargin[3]) " h" (Height + CaptureMargin[4]), GDI+ WinCap

while (true)
{
    WinGetPos,,, Width, Height, % "ahk_id" CaptureHandle
       
    if (Mod(A_Index, 200) == 1)
    {
        GuiSize()
    }
   
    DC := CreateCompatibleDC()
    DIB := CreateDIBSection(Width, Height)
   
    SelectObject(DC, DIB)
    PrintWindow(CaptureHandle, DC, 2)
   
    DDC := GetDC(GuiPictureHandle)
    Bitmap := Gdip_CreateBitmapFromHBITMAP(DIB)
    Graphics := Gdip_GraphicsFromHDC(DC)
   
    Gdip_DrawImage(Graphics, Bitmap)
    Gdip_DisposeImage(Bitmap)
    DeleteObject(Graphics)
   
    BitBlt(DDC, 0, 0, Width, Height, DC, 0, 0)
    DeleteObject(DIB)
   
    ReleaseDC(DDC)
    DeleteDC(DC)
}

GuiSize:
{
    GuiSize()
}

GuiSize()
{
    global CaptureHandle, CaptureMargin, GuiHandle, GuiPictureHandle
   
    WinGetPos, CapX, CapY, CapW, CapH, % "ahk_id" CaptureHandle
    WinGetPos, WinX, WinY, WinW, WinH, % "ahk_id" GuiHandle
   
    CapW := (CapW + CaptureMargin[3])
    CapH := (CapH + CaptureMargin[4])
   
    if ((WinW > CapW) || (WinH > CapH))
    {
        WinMove, % "ahk_id " GuiHandle, , % WinX, % WinY, % CapW, % CapH
    }
    else if ((WinW < (CapW / 2)) || (WinH < (CapH / 2)))
    {
        WinMove, % "ahk_id " GuiHandle, , % WinX, % WinY, % (CapW / 2), % (CapH / 2)
    }
   
    WinMove, % "ahk_id" GuiPictureHandle, , % CaptureMargin[1], % CaptureMargin[2], % WinW, % WinH
}

#IfWinActive ahk_class AutoHotkeyGUI
Esc::

GuiClose:
{
    ExitApp
}

CaptureSelection:
{
    GuiControlGet, CaptureText
    Gui, Show, Hide
   
    return
}


@J2Kbr:

Are there any advanced configuration options that can be used to change how Gtuner captures the window?
User avatar
PaulaTheKoala
Command Sergeant Major
Command Sergeant Major
 
Posts: 131
Joined: Wed Aug 26, 2015 3:45 am

Re: Gtuner IV 1.07 PUBLIC RELEASE: Computer Vision

Postby J2Kbr » Thu Apr 02, 2020 5:24 pm

PaulaTheKoala wrote:Been busy and haven't been on lately, just seen this, nice work! :joia: I've actually been doing something similar to this via the T1 API and Remote Play for a while now lol. I look forward to seeing what others create with this. :)

Nice see you back. What you've been doing with CV? maybe we can port for the Titan Two. :smile0517:
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: Gtuner IV 1.07 BETA (Scriptable Computer Vision Interfac

Postby J2Kbr » Thu Apr 02, 2020 5:26 pm

prototype wrote:
DontAtMe wrote:
J2Kbr wrote: The aspect ratio is also wrong with the others available resolutions? (e.g. 1280x720)
Yes, all of the resolutions output at 4:3.
Have you found a way to fix that?

Maybe, have you tried the "MS DirectShow" backend to check if the aspect ratio is read correctly?
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: Gtuner IV 1.07 PUBLIC RELEASE: Computer Vision

Postby J2Kbr » Thu Apr 02, 2020 5:31 pm

grarrg wrote:I updated the app and when I tried to launch I got this error: Gtuner.exe - System Error "The code execution cannot proceed because zlibwapi.dll was not found. Reinstalling the program may solve this problem." Did I lose all my saved data?

The 1.07 release has also updated the Qt framework which Gtuner IV is based on. This requires update basically all Gtuner installation and, in some circumstances, may fail due a bug in ‘Gupdater.exe’ helper application from previous version. This bug has also been fixed on 1.07. In case of error after the update procedure, the solution is redownload Gtuner IV from the ConsoleTuner website:

https://www.consoletuner.com/titan-two-downloads/

Unzip and just replace the Gtuner IV installation directory. All your saved data will be kept. :smile0517:
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: Gtuner IV 1.07 PUBLIC RELEASE: Computer Vision

Postby J2Kbr » Thu Apr 02, 2020 5:35 pm

SixtySix wrote:I'm not an expert in capturing video in this way but I did get it (mostly) to work. Having an issue though. Window capture is not working for any windows other than the gtuner window itself. I've tried the Xbox app window, streaming window, have tried internet windows just to see. They all appear as a black screen but give no errors. Gtuner appears fine when I capture that window. Using display capture I can capture my entire monitor just fine, but that's not really what I'm looking for. I'd like to capture just the smaller streaming window, any ideas on what the issue is? Edit: I can also capture the file system window just fine. But any app windows I have tried (such as calculator) are just black screen. Very confused.

For some applications, such as Xbox App, "Window Capture" does not work. For these cases use "Display Capture". You can find more information about this here: viewtopic.php?f=0&t=14717&p=95695#p95695
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: Gtuner IV 1.07 PUBLIC RELEASE: Computer Vision

Postby J2Kbr » Thu Apr 02, 2020 5:49 pm

PaulaTheKoala wrote:Are there any advanced configuration options that can be used to change how Gtuner captures the window?

The capture is performed on Python, using the PyWin32 module (win32 api calls: GetWindowDC, CreateDCFromHandle, CreateBitmap, BitBlt, etc). Do you mind share with me the solution you found with GDI+ Library? If okay, please PM me, this will save me time on researching. Thank you in advance.
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: Gtuner IV 1.07 PUBLIC RELEASE: Computer Vision

Postby PaulaTheKoala » Fri Apr 03, 2020 1:19 am

J2Kbr wrote:
PaulaTheKoala wrote:Been busy and haven't been on lately, just seen this, nice work! :joia: I've actually been doing something similar to this via the T1 API and Remote Play for a while now lol. I look forward to seeing what others create with this. :)

Nice see you back. What you've been doing with CV? maybe we can port for the Titan Two. :smile0517:


Nothing too advanced, I was using it to automate a repetitive game. I was using a C# application for handling button events via the T1 API and a AutoHotkey script to scan the Remote Play window for certain images (via built-in ImageSearch command) and sends back button events using SendMessage and WM_COPYDATA.

J2Kbr wrote:
PaulaTheKoala wrote:Are there any advanced configuration options that can be used to change how Gtuner captures the window?

The capture is performed on Python, using the PyWin32 module (win32 api calls: GetWindowDC, CreateDCFromHandle, CreateBitmap, BitBlt, etc). Do you mind share with me the solution you found with GDI+ Library? If okay, please PM me, this will save me time on researching. Thank you in advance.


The solution I have was posted in my previous comment but it's written in AutoHotKey and uses a GDI+ helper library, while doing research on this subject I also discovered that you can use the Magnification API to capture screenshots, you can even filter out other windows so that you can capture overlaid windows.

Unfortunately I have work soon so I can't do much right now, but I'll gladly take a look at PyWin32 when I get home. :)
User avatar
PaulaTheKoala
Command Sergeant Major
Command Sergeant Major
 
Posts: 131
Joined: Wed Aug 26, 2015 3:45 am

Re: Gtuner IV 1.07 BETA (Scriptable Computer Vision Interfac

Postby Prototype » Fri Apr 03, 2020 1:57 pm

J2Kbr wrote:Maybe, have you tried the "MS DirectShow" backend to check if the aspect ratio is read correctly?

I had tried them all before, they didn't worked but today the "MS DirectShow" works fine. Thanks :smile0517:
You can add the Liver Gamer HD2 in the supported cards.
Console tuner since my 1st controller.
Scripting, a game in the game.
Believe or dare, It's Titanic! :smile0517:
User avatar
Prototype
Major General
Major General
 
Posts: 3251
Joined: Sun Dec 16, 2012 1:43 pm

Re: Gtuner IV 1.07 PUBLIC RELEASE: Computer Vision

Postby J2Kbr » Fri Apr 03, 2020 3:11 pm

PaulaTheKoala wrote:The solution I have was posted in my previous comment

I will be checking if this API is supported by PyWin32 module. Thank you.
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: Gtuner IV 1.07 BETA (Scriptable Computer Vision Interfac

Postby J2Kbr » Fri Apr 03, 2020 3:12 pm

prototype wrote:
J2Kbr wrote:Maybe, have you tried the "MS DirectShow" backend to check if the aspect ratio is read correctly?

I had tried them all before, they didn't worked but today the "MS DirectShow" works fine. Thanks :smile0517:
You can add the Liver Gamer HD2 in the supported cards.

That is awesome! Thank you for check and confirm! :joia: :joia: :joia:
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

PreviousNext

Return to News and Announcements

Who is online

Users browsing this forum: No registered users and 66 guests