Jump to content

Recommended Posts

  • 2 weeks later...
Posted

Thanks @malcev

I saw that project but I was not satisfied.
I wrote a mediapipe binding that is similar to the python binding. It is not published yet because it is in the testing phase.
Once done, it will be published.

Posted

@smbape can you move developing your UDF to github ?
I think then we can start involving.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Hi @malcev

The environment variable is intended to override the embeded manifest.
It is not needed for scripting languages, but for compiled languages.
That being said, I kept it just in case.

For example, to use registration-free COM at compile time for opencv and mediapipe, the manifest used for activation context must have all the dependencies.
Since each of the libraries has its own manifest, environment varaibles are a way to reduce the complexity of specifying a manifest per library.

The following manisfest was put in a file
 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    <assemblyIdentity type="win32" name="mediapipe.sxs" version="0.3.0.0" />

    <dependency>
        <dependentAssembly>
            <assemblyIdentity type="win32" name="autoit_opencv_com470.sxs" version="2.3.1.0" />
        </dependentAssembly>
    </dependency>

    <dependency>
        <dependentAssembly>
            <assemblyIdentity type="win32" name="autoit_mediapipe_com-0.9.1-470.sxs" version="0.3.0.0" />
        </dependentAssembly>
    </dependency>
</assembly>

and the environment variables point to that file, like in this c# example

https://github.com/smbape/node-autoit-mediapipe-com/blob/main/autoit-mediapipe-com/test/test.cs#L242

Posted

Thank You for explanation.

Can We activate manifest only 1 time at start with DllActivateManifest, and deactivate it only before exit script with DllDeactivateActCtx?

Can be some memory leaks?

Also if We exit script without calling DllDeactivateActCtx, will be some memory leaks?

Posted

I thought about it, but there are cases where the current activation context changes and that's because the activation contexts are per thread.
When a callback registered with DllCallbackRegister is called, the activation context changes.
Therefore, creating objects (in a c++ method or in autoit) will no longer work since the current activation context is not the one that contains the information about the COM objects.

There is also the case where different activation contexts are needed for different objects. For example if you use opencv and mediapipe at the same time.
To handle such a case, the manifest used for activation must have all dependencies, i.e. opencv and mediapipe.
But this is not enough, because the use in callbacks will not work.

From Microsoft about Isolating Components

  Quote

Well-authored components do not perturb the environment of the hosting application, nor do they leak activation contexts. Well-authored components perform their own context management rather than relying on the hosting application's environment.

Expand  

Activating before creating an object (_OpenCV_ObjCreate) or before calling a method/property (c++ GetTypeInfo/GetIDsOfNames/Invoke) ensures that the library objects always work.
Deactivating the context ensures that the library does not perturb the the environment of the hosting application.

Posted
  On 2/26/2023 at 4:25 AM, malcev said:

Can be some memory leaks?

Expand  

I don't understand the question.
What makes you think of memory leaks.

 

  On 2/26/2023 at 4:25 AM, malcev said:

Also if We exit script without calling DllDeactivateActCtx, will be some memory leaks?

Expand  

No, when your script dies, the memory associated with your script dies too.
Perhaps you mean something else.

  • 2 weeks later...
  • 1 month later...
Posted

Dunno if you'll ever read this, but I wanted to let you know that I'm testing this out and so far it's looking really great - wanted to commend you for the hard work on this - very incredible stuff, kudos!

  • 2 weeks later...
Posted

There is no prebuilt opencv 32 bit.
If you really need it, you have to compile opencv and the com library for 32bit yourself.

  • 10 months later...
Posted

Share some information :

Bitmap to mat :

$cv.createMatFromBitmap($hImage2_o) 

 

Resolve other language code page path issue :

Local $STextHex = StringToBinary($_MODEL_FILE,1)
Local $tString = DllStructCreate("byte txt[" & BinaryLen($STextHex) & "]")
$tString.txt = $STextHex
Local $stringcc = _WinAPI_MultiByteToWideChar($tString, 1252, Default, True)

Local $base_options = $autoit.BaseOptions(_Mediapipe_Params("model_asset_path", $stringcc))

Posted

Thanks @konya

Can you give more information, a test case for example, about the code page path issue?
I would have tough that Local $base_options = $autoit.BaseOptions(_Mediapipe_Params("model_asset_path", $_MODEL_FILE)) would have worked.

Posted (edited)

When I use chinese path open image or mediapipe ,it is will crash,convet code page to 1252 resolve issue.

 

$_MODEL_FILE = "c:\測試\test.jpg"

Local $STextHex = StringToBinary($_MODEL_FILE,1)

Local $tString = DllStructCreate("byte txt[" & BinaryLen($STextHex) & "]")

$tString.txt = $STextHex

Local $stringcc = _WinAPI_MultiByteToWideChar($tString, 1252, Default, True)

 

 

issue.JPG

 

Perfect.JPG

Edited by konya
Posted

@konya There was actually a bug with non ascii strings.

I have tested language detector with mediapipe without issues.

Could you please retry with the new version without your workaround and tell me if it solves your issue?

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...