Results 1 to 21 of 21

Thread: how can used pipe to load this console without first starting the cmd.exe like python

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    618

    how can used pipe to load this console without first starting the cmd.exe like python

    Take python as an example:

    Code:
    ret = subprocess.Popen("Program directory\ PaddleOCR_json.exe -- use_debug=0", cwd="Program directory",stdout=subprocess. PIPE,stdin=subprocess. PIPE,)
    Program directory must be specified

    I now need to load a console program through the pipe

    Code:
       Cexec with wqw
    
         Set oP = New cExec
       ' oP.Run Environ$("COMSPEC"), "/Q"   ', StartHidden:=True
        oP.Run "C:\Users\Lenovo\Desktop\PaddleOCR-json.v1.2.1\PaddleOCR_json.exe", vbNullString  ', StartHidden:=True 'cannot work ok , The program cannot find the configuration file because no directory is specified



    if i changed to this can work ok

    Code:
        Set oP = New cExec
        oP.Run Environ$("COMSPEC"), "/Q"   ', StartHidden:=True
        'oP.Run "cmd.exe", vbNullString  ', StartHidden:=True
    
         Print SendCommand("cd C:\Users\Lenovo\Desktop\PaddleOCR-json.v1.2.1") ----- Must be set 
    
      '  Stop
        Print SendCommand("PaddleOCR_json.exe", "OCR init completed", 5) ' now work ok
       but have a question cannot used  oP.KillProcess to closed  PaddleOCR_json.exe
      
    must used  Shell "TASKKILL /F /IM PaddleOCR_json.exe /T"
    used Cexec.cls and have the same question. thanks

    IF I ADD ClurrentDirectory

    Public Function Run(sFile As String, _
    sParams As String, ClurrentDirectory As String, _
    Optional ByVal StartHidden As Boolean, _
    Optional ByVal StartMinimized As Boolean, _
    Optional ByVal LimitFlags As Long) As Boolean

    If CreateProcessA(vbNullString, sCommandLine, 0, 0, 1, NORMAL_PRIORITY_CLASS, 0, ClurrentDirectory, uStart, uProcInfo)

    oP.Run "C:\Users\Lenovo\Desktop\PaddleOCR-json.v1.2.1\PaddleOCR_json.exe", vbNullString, "C:\Users\Lenovo\Desktop\PaddleOCR-json.v1.2.1" ', StartHidden:=True

    also cannot worked ok

    How to directly load the console program without first starting the cmd.exe like the python code

    dilettante's shellpipe work ok

    Code:
    i change wqw cExec.cls form dilettante shellpipe
    Private Declare Function CreateProcessA _
                    Lib "kernel32" (ByVal lpApplicationName As String, _
                                    ByVal lpCommandLine As String, _
                                    ByVal lpProcessAttributes As Long, _
                                    ByVal lpThreadAttributes As Long, _
                                    ByVal bInheritHandles As Long, _
                                    ByVal dwCreationFlags As Long, _
                                    ByVal lpEnvironment As Long, _
                                    ByVal lpCurrentDirectory As Long, _
                                    lpStartupInfo As STARTUPINFO, _
                                    lpProcessInformation As PROCESS_INFORMATION) As Long
    
    Public Function Run(sFile As String, _
                        sParams As String, _
                        CurrentDir As String, _
                        Optional ByVal StartHidden As Boolean, _
                        Optional ByVal StartMinimized As Boolean, _
                        Optional ByVal LimitFlags As Long) As Boolean
    .....
        
     Dim AnsiCurrentDir() As Byte
         Dim pAnsiCurrentDir As Long
        If Len(CurrentDir) > 0 Then
            AnsiCurrentDir = StrConv(CurrentDir, vbFromUnicode)
            ReDim Preserve AnsiCurrentDir(UBound(AnsiCurrentDir) + 1) 'Add Nul.
            pAnsiCurrentDir = VarPtr(AnsiCurrentDir(0))
        'Else 'Happens implicitly anyway so we comment these lines out.
        '    pAnsiCurrentDir = WIN32NULL
        End If
    .....
    If CreateProcessA(vbNullString, sCommandLine, 0, 0, 1, NORMAL_PRIORITY_CLASS, 0, pAnsiCurrentDir, uStart, uProcInfo) <> 0 Then
    but can alse work not ok
    Last edited by xxdoc123; Oct 3rd, 2022 at 12:35 AM.

  2. #2
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    4,287

    Re: how can used pipe to load this console without first starting the cmd.exe like py

    Here is an updated version of cExec class which has additional CurrentDir parameter to its Run method.

    This simply sets current directory of the launched process the way you tried to do it using CreateProcess API (no idea why this failed w/ you).

    Tested like this

    Code:
    Private Sub Form_Load()
        With New cExec
            .Run "cmd", "/c dir", StartHidden:=True, CurrentDir:="C:\TEMP"
            Debug.Print Left$(.ReadAllOutput, 1000)
        End With
    End Sub
    . . . which dumps in Immediate Window something like this

    Code:
     Volume in drive C has no label.
     Volume Serial Number is 96F1-A722
    
     Directory of C:\TEMP
    
    19.07.2022  13:21    <DIR>          .
    18.03.2022  15:51    <DIR>          aida64extreme660
    18.03.2022  16:44    <DIR>          Drivers
    . . .
    cheers,
    </wqw>

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    618

    Re: how can used pipe to load this console without first starting the cmd.exe like py

    I will test the new version. thanks

    After the console program is started, it will wait for the user to enter instructions and then return data until the user closes the console. Otherwise, the console is waiting in the background.

    https://github.com/hiroi-sora/PaddleOCR-json
    Last edited by xxdoc123; Oct 3rd, 2022 at 06:09 AM.

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    618

    Re: how can used pipe to load this console without first starting the cmd.exe like py

    Quote Originally Posted by wqweto View Post
    Here is an updated version of cExec class which has additional CurrentDir parameter to its Run method.

    This simply sets current directory of the launched process the way you tried to do it using CreateProcess API (no idea why this failed w/ you).

    Tested like this

    Code:
    Private Sub Form_Load()
        With New cExec
            .Run "cmd", "/c dir", StartHidden:=True, CurrentDir:="C:\TEMP"
            Debug.Print Left$(.ReadAllOutput, 1000)
        End With
    End Sub
    . . . which dumps in Immediate Window something like this

    Code:
     Volume in drive C has no label.
     Volume Serial Number is 96F1-A722
    
     Directory of C:\TEMP
    
    19.07.2022  13:21    <DIR>          .
    18.03.2022  15:51    <DIR>          aida64extreme660
    18.03.2022  16:44    <DIR>          Drivers
    . . .
    cheers,
    </wqw>
    Code:
    Set oP = New cExec
       
        'oP.Run Environ$("COMSPEC"), "/Q"   ', StartHidden:=True
        oP.Run "C:\Users\Lenovo\Desktop\PaddleOCR-json.v1.2.1\PaddleOCR_json.exe", "", , , , "C:\Users\Lenovo\Desktop\PaddleOCR-json.v1.2.1\" ', 
       ' Debug.Print oP.ReadOutput(1000)
    Sorry, I just have time to test. With the new version, the console program still fails to load the configuration file and return data

  5. #5
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    4,287

    Re: how can used pipe to load this console without first starting the cmd.exe like py

    Just tested this

    Code:
    Private Sub Form_Load()
        With New cExec
    '        .Run "cmd", "/c dir", StartHidden:=True, CurrentDir:="C:\TEMP\"
            .Run "cmd", "/c dir", , , , "C:\Users\Lenovo\Desktop\PaddleOCR-json.v1.2.1\"
            Debug.Print Left$(.ReadAllOutput, 1000)
        End With
    End Sub
    . . . and got this

    Code:
     Volume in drive C has no label.
     Volume Serial Number is 96F1-A722
    
     Directory of C:\Users\Lenovo\Desktop\PaddleOCR-json.v1.2.1
    
    04.10.2022  11:38    <DIR>          .
    04.10.2022  11:38    <DIR>          ..
    . . . so the process is launched in correct directory here.

    cheers,
    </wqw>

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    618

    Re: how can used pipe to load this console without first starting the cmd.exe like py

    Quote Originally Posted by wqweto View Post
    Just tested this

    Code:
    Private Sub Form_Load()
        With New cExec
    '        .Run "cmd", "/c dir", StartHidden:=True, CurrentDir:="C:\TEMP\"
            .Run "cmd", "/c dir", , , , "C:\Users\Lenovo\Desktop\PaddleOCR-json.v1.2.1\"
            Debug.Print Left$(.ReadAllOutput, 1000)
        End With
    End Sub
    . . . and got this

    Code:
     Volume in drive C has no label.
     Volume Serial Number is 96F1-A722
    
     Directory of C:\Users\Lenovo\Desktop\PaddleOCR-json.v1.2.1
    
    04.10.2022  11:38    <DIR>          .
    04.10.2022  11:38    <DIR>          ..
    . . . so the process is launched in correct directory here.

    cheers,
    </wqw>
    This will return the correct directory list~

    Code:
    oP.Run "C:\Users\Lenovo\Desktop\PaddleOCR-json.v1.2.1\PaddleOCR_json.exe", "", , , , "C:\Users\Lenovo\Desktop\PaddleOCR-json.v1.2.1\"
    But it does not work when calling the PaddleOCR_json.exe console,shellpipe can work ok.why .

    Code:
     ShellPipe.Run("C:\Users\Lenovo\Desktop\PaddleOCR-json.v1.2.1\PaddleOCR_json.exe", "C:\Users\Lenovo\Desktop\PaddleOCR-json.v1.2.1\")
    ----used timer Get data asynchronously
    -> fetch
    Active code page: 65001
    OCR init completed.
    i want Write program without form
    Last edited by xxdoc123; Oct 4th, 2022 at 04:40 AM.

  7. #7
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    4,287

    Re: how can used pipe to load this console without first starting the cmd.exe like py

    Quote Originally Posted by xxdoc123 View Post
    But it does not work when calling the PaddleOCR_json.exe console,shellpipe can work ok.why .
    No idea. ShellPipe might be better for what you are doing in this case.

    If we have to apply common sense i.e. some basic logic -- it seems your problem is *not* current directory the process is launched in because current directory works with cExec already, so it must be something else.

    Launched process inherits parent process environment, including PATH variable. It's hard to guess what PaddleOCR_json.exe does and how does it search for its configuration but could be related.

    Another option is elevated vs non-elevated execution, this makes a difference with regards to which files/paths are accessible.

    cheers,
    </wqw>

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    618

    Re: how can used pipe to load this console without first starting the cmd.exe like py

    Quote Originally Posted by wqweto View Post
    No idea. ShellPipe might be better for what you are doing in this case.

    If we have to apply common sense i.e. some basic logic -- it seems your problem is *not* current directory the process is launched in because current directory works with cExec already, so it must be something else.

    Launched process inherits parent process environment, including PATH variable. It's hard to guess what PaddleOCR_json.exe does and how does it search for its configuration but could be related.

    Another option is elevated vs non-elevated execution, this makes a difference with regards to which files/paths are accessible.

    cheers,
    </wqw>
    thanks sir
    Code:
       
     Set oP = New cExec
        oP.Run Environ$("COMSPEC"), "/Q"   ', StartHidden:=True
        'oP.Run "cmd.exe", vbNullString  ', StartHidden:=True
    
         Print SendCommand("cd C:\Users\Lenovo\Desktop\PaddleOCR-json.v1.2.1") ----- Must be set 
    
      '  Stop
        Print SendCommand("PaddleOCR_json.exe", "OCR init completed", 5) ' now work ok
       but have a question cannot used  oP.KillProcess to closed  PaddleOCR_json.exe
      
       must used  Shell "TASKKILL /F /IM PaddleOCR_json.exe /T"
    The problem is back to the starting point.i must start cmd.exe .At present, we have to adopt this method




    Code:
    With oP
            .Run "cmd", "",CurrentDir:= "C:\Users\Lenovo\Desktop\PaddleOCR-json.v1.2.1"
           
        End With
       
        Debug.Print SendCommand("PaddleOCR_json.exe", "OCR init completed", 5)'  work ok ,
    Public Function SendCommand(sCommand As String, _
                                Optional sTerminator As String, _
                                Optional Timeout As Double = 2, _
                                Optional ByVal UseDoEvents As Boolean = True) As String
        Dim sRetVal  As String
        Dim dblTimer As Double
        
        dblTimer = Timer
    
        If Not oP.AtEndOfOutput And Len(sCommand) > 0 Then
            oP.WriteInput sCommand & vbCrLf
        End If
    
    
        Do While Not oP.AtEndOfOutput
    
            If UseDoEvents Then
    
                DoEvents
            Else
                Call Sleep(1)
            End If
    
            sRetVal = sRetVal & oP.ReadPendingOutput & oP.ReadPendingError
    
            If InStr(sRetVal, sTerminator) > 0 Then
                Exit Do
            End If
    
            If Timeout > 0 Then
                If Timer > dblTimer + Timeout Then
                    Exit Do
                End If
            End If
    
        Loop
    
        SendCommand = sRetVal
    End Function
    The path problem has been solved. It seems that this method must be Execute in cmd.exe
    Last edited by xxdoc123; Nov 19th, 2022 at 09:00 PM.

  9. #9
    PowerPoster
    Join Date
    Jun 2013
    Posts
    6,240

    Re: how can used pipe to load this console without first starting the cmd.exe like py

    Why not place a little "Do_OCR.cmd"-File in the App-Path (which contains a "leading cd-command") -
    and then Execute this file instead?

    Has the advantage, that it would be even "User/Admin-customizable" with Notepad.exe
    (without changing your Application-Executable).

    Olaf

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    618

    Re: how can used pipe to load this console without first starting the cmd.exe like py

    Quote Originally Posted by Schmidt View Post
    Why not place a little "Do_OCR.cmd"-File in the App-Path (which contains a "leading cd-command") -
    and then Execute this file instead?

    Has the advantage, that it would be even "User/Admin-customizable" with Notepad.exe
    (without changing your Application-Executable).

    Olaf
    Code:
    ''Do_OCR.cmd
    C:\Users\Lenovo\Desktop\PaddleOCR-json.v1.2.1\PaddleOCR_json.exe
    Is it written like this? It seems that the returned data cannot be obtained
    Last edited by xxdoc123; Oct 4th, 2022 at 08:07 AM.

  11. #11
    PowerPoster
    Join Date
    Jun 2013
    Posts
    6,240

    Re: how can used pipe to load this console without first starting the cmd.exe like py

    Quote Originally Posted by xxdoc123 View Post
    Code:
    ''Do_OCR.cmd
    C:\Users\Lenovo\Desktop\PaddleOCR-json.v1.2.1\PaddleOCR_json.exe
    Is it written like this? It seems that the returned data cannot be obtained
    What I meant was, to put the following text-content into a "cmd-script file" (a batch-file, if you want):
    Code:
    :: switch off echoing of commands
    @echo OFF
    
    :: change to a differrent directory (inside this console-script)    
    cd c:\Windows  
    
    :: explicitely echo/print the current directory this console now runs in, to stdout 
    echo %cd%
    
    :: explicitely echo/print the 1st and 2nd parameter, passed to this script 
    echo %1%
    echo %2%
    
    :: now run a program with params, and capture additional (std)output
    ping localhost
    If you named this text-file as:
    test.cmd
    and if you placed it in c:\temp\test.cmd

    then you can already check stdoutput-retrieval with this little VB6-codesnippet:
    Code:
    Option Explicit
    
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    
    Private Sub Form_Load()
      Debug.Print ShellAndWaitWithStdOut("c:\temp\test.cmd  MyFirstParameter MySecondParameter")
    End Sub
    
    Private Function ShellAndWaitWithStdOut(CommandLine As String) As String
      With CreateObject("WScript.Shell").Exec(CommandLine)
        Do Until .Status: Sleep 100: Loop        'wait for process to finish
        
        ShellAndWaitWithStdOut = .StdOut.ReadAll 'return the StdOutput
      End With
    End Function
    HTH

    Olaf

  12. #12

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    618

    Re: how can used pipe to load this console without first starting the cmd.exe like py

    Quote Originally Posted by Schmidt View Post
    What I meant was, to put the following text-content into a "cmd-script file" (a batch-file, if you want):
    Code:
    :: switch off echoing of commands
    @echo OFF
    
    :: change to a differrent directory (inside this console-script)    
    cd c:\Windows  
    
    :: explicitely echo/print the current directory this console now runs in, to stdout 
    echo %cd%
    
    :: explicitely echo/print the 1st and 2nd parameter, passed to this script 
    echo %1%
    echo %2%
    
    :: now run a program with params, and capture additional (std)output
    ping localhost
    If you named this text-file as:
    test.cmd
    and if you placed it in c:\temp\test.cmd

    then you can already check stdoutput-retrieval with this little VB6-codesnippet:
    Code:
    Option Explicit
    
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    
    Private Sub Form_Load()
      Debug.Print ShellAndWaitWithStdOut("c:\temp\test.cmd  MyFirstParameter MySecondParameter")
    End Sub
    
    Private Function ShellAndWaitWithStdOut(CommandLine As String) As String
      With CreateObject("WScript.Shell").Exec(CommandLine)
        Do Until .Status: Sleep 100: Loop        'wait for process to finish
        
        ShellAndWaitWithStdOut = .StdOut.ReadAll 'return the StdOutput
      End With
    End Function
    HTH

    Olaf
    thanks
    your code Is it possible to input parameters!In fact, the ocr program does not need to configure parameters when it starts, because it will read the configuration file in the directory where the program is located

    Code:
    @echo OFF
    cd C:\Users\Lenovo\Desktop\PaddleOCR-json.v1.2.1
    
    PaddleOCR_json.exe
    No data is returned after the program is started. It seems that the process is blocked

  13. #13
    PowerPoster
    Join Date
    Jun 2013
    Posts
    6,240

    Re: how can used pipe to load this console without first starting the cmd.exe like py

    Quote Originally Posted by xxdoc123 View Post
    No data is returned after the program is started. It seems that the process is blocked
    In that case, the Paddle-Executable is perhaps not changing the Status (from Zero), when finished...

    But changing the looping-criteria is not rocket-science either:
    Code:
    Option Explicit
    
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    
    Private Sub Form_Load()
      Debug.Print ShellAndWaitWithStdOut("c:\temp\test.cmd")
    End Sub
    
    Private Function ShellAndWaitWithStdOut(CommandLine As String) As Boolean
      With CreateObject("WScript.Shell").Exec(CommandLine)
      
        Do Until .StdOut.ReadLine = "finished"
           Sleep 15
        Loop
        
        ShellAndWaitWithStdOut = True
      End With
    End Function
    The above should work with the following content in your test.cmd-file:
    Code:
    @echo OFF
    cd C:\Users\Lenovo\Desktop\PaddleOCR-json.v1.2.1
    PaddleOCR_json.exe
    echo finished
    HTH

    Olaf

  14. #14

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    618

    Re: how can used pipe to load this console without first starting the cmd.exe like py

    Quote Originally Posted by Schmidt View Post
    In that case, the Paddle-Executable is perhaps not changing the Status (from Zero), when finished...

    But changing the looping-criteria is not rocket-science either:
    Code:
    Option Explicit
    
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    
    Private Sub Form_Load()
      Debug.Print ShellAndWaitWithStdOut("c:\temp\test.cmd")
    End Sub
    
    Private Function ShellAndWaitWithStdOut(CommandLine As String) As Boolean
      With CreateObject("WScript.Shell").Exec(CommandLine)
      
        Do Until .StdOut.ReadLine = "finished"
           Sleep 15
        Loop
        
        ShellAndWaitWithStdOut = True
      End With
    End Function
    The above should work with the following content in your test.cmd-file:
    Code:
    @echo OFF
    cd C:\Users\Lenovo\Desktop\PaddleOCR-json.v1.2.1
    PaddleOCR_json.exe
    echo finished
    HTH

    Olaf
    In fact, it has not been run 'echo finished' . Only the black window of the console is closed ,can return data 'finished'
    I don't why know

  15. #15
    PowerPoster
    Join Date
    Jun 2013
    Posts
    6,240

    Re: how can used pipe to load this console without first starting the cmd.exe like py

    Quote Originally Posted by xxdoc123 View Post
    Only the black window of the console is closed...
    In that case, all commands in it were finished (including your PaddleOCR-execute).

    If you want to "see something" on the console, then comment out the first line
    (either via :: or REM)...

    Olaf

  16. #16
    PowerPoster
    Join Date
    Jun 2013
    Posts
    6,240

    Re: how can used pipe to load this console without first starting the cmd.exe like py

    To get potential errors back into the VB6-App, changing the function to:
    Code:
    Private Function ShellAndWaitWithStdOut(CommandLine As String) As Boolean
      With CreateObject("WScript.Shell").Exec(CommandLine)
      
        Do: Sleep 15
            Dim S: S = .StdErr.ReadLine
            If Len(S) Then Debug.Print S: Exit Function
        Loop Until .StdOut.ReadLine = "finished"
        
        ShellAndWaitWithStdOut = True
      End With
    End Function
    ...might help as well...

    Olaf

  17. #17

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    618

    Re: how can used pipe to load this console without first starting the cmd.exe like py

    I have seen similar code in this link by you.

    Maybe it's the console. Maybe it's something else. '.StdOut.ReadLine Always return null.If some peoples have time, can try to test

    https://github.com/hiroi-sora/PaddleOCR-json

    if run ok may return
    Code:
    -> fetch
    Active code page: 65001
    OCR init completed.
    This is an unreasonable request~

    Maybe there's no such direct way

  18. #18
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    4,287

    Re: how can used pipe to load this console without first starting the cmd.exe like py

    This is the relevant function from tools.cpp for loading the congif (sic) files

    Code:
      void load_congif_file() {
    	// МбИЎТСУРFlags
    	std::vector<google::CommandLineFlagInfo> allFlags;
    	GetAllFlags(&allFlags);
    
    	// БИлЕдЦГОДјю
    	bool isDefaultDir = false;
    	if (FLAGS_config_path == "") { // ОґґИлЕдЦГОДјюВѕЈФтДИПВѕОЄ іМРтГы+єуЧє 
    	  string exe_name = google::ProgramInvocationShortName();
    	  string::size_type dPos = exe_name.rfind('.'); // ЧоєуТёцгОЦГ
    	  FLAGS_config_path = exe_name.substr(0, dPos) + (string)"_config.txt";
    	  isDefaultDir = true;
    	}
    	ifstream inConf(FLAGS_config_path);
    	if (!inConf) { // ґИлЕдЦГОДјюІґжФЪКЁґн
    	  if (!isDefaultDir) std::cerr << "[ERROR] config path not exist! config_dir: " << FLAGS_config_path << endl;
    	  return;
    	}
    
    	// ЅвОцЕдЦГОДјю
    	string s;
    	while (getline(inConf, s)) // ґРРБИлРЕПў 
    	{
    	  if (s[0] == '#') continue; // ЕЕіэЧўКН 
    	  string key, value;
    	  if (!get_line_config(s, key, value)) continue; // ЅвОцТРРЕдЦГ 
    
    	   // ЙиЦГТЧйЕдЦГЎЈЧФЇјмСйКЗсґжФЪєНєПЁРФЎЈУЕПИјНУЪЖфЇІОКэЎЈ
    	  google::SetCommandLineOptionWithMode(key.c_str(), value.c_str(), google::SET_FLAG_IF_DEFAULT);
    	}
    	inConf.close();
      }
    Location of the "congif" file has *nothing* to do with current directory the process is launched into so the initial root cause analysis above seems very probable now.

    This FLAGS_config_path = exe_name.substr(0, dPos) + (string)"_config.txt" is used when no command-line parameters are passed.

    Not sure exactly but probably config_path c:\path\to\config.txt can be used as a command-line parameter to explicitly pass the "congif" file (which is not in JSON format but a plain-text file).

    The README says something about static vs dynamic parameters but obviously sucks tremendously because there is no sample of launching the tool w/ some command-line parameters.

    cheers,
    </wqw>

  19. #19

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    618

    Re: how can used pipe to load this console without first starting the cmd.exe like py

    thanks.
    yes !I did not change the parameters, but simply run the program. The default parameters are in the text in the folder where the program is located. The configuration will be acquired automatically after startup.
    if run worked ok will show this
    Code:
    OCR init completed.
    And wait for the user to transfer the parameters
    Last edited by xxdoc123; Oct 5th, 2022 at 01:25 AM.

  20. #20
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    4,287

    Re: how can used pipe to load this console without first starting the cmd.exe like py

    > The default parameters are in the text in the folder where the program is located

    Yes, this is correct.

    Edit: Now I see it's using exe_name = google::ProgramInvocationShortName() which can be problematic if your exe name is PaddleOCR_json.exe as short name is PADDLE~1.EXE so your config file should be in PADDLE~1_config.txt which is unexpected.

    On Win10+ short names are enabled only on C: drive i.e. on D: drive there are no short names so the config file has to be differently named depending on if exe is located in C: or in D: drive which is mind-boggling.

    You might try renaming executable to padocr.exe and config to padocr_config.txt too to reduce "ooops" moments with this utility.

    cheers,
    </wqw>

  21. #21

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    618

    Re: how can used pipe to load this console without first starting the cmd.exe like py

    thank you. If it is really the problem of the original console, I will try to communicate with the author. It seems that you have found the real reason.

    I asked author,he said he don't used short path in this project
    Last edited by xxdoc123; Oct 5th, 2022 at 08:01 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width