Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CascadeClassifier constructor #1730

Open
paredominic opened this issue Dec 9, 2024 · 0 comments
Open

CascadeClassifier constructor #1730

paredominic opened this issue Dec 9, 2024 · 0 comments

Comments

@paredominic
Copy link

Summary of your issue

Add a constructor to the CascadeClassifier object to be able to load a classifier from a string or resource. We need to carry as files the XML files with our bin.

Environment

All

What did you do when you faced the problem?

Nothing

Example code:

        Dim tempFilePath As String = "haarcascade_frontalface_alt2.xml"

        If Not IO.File.Exists(tempFilePath) Then

            Dim resourceBytes() As Byte = System.Text.Encoding.UTF8.GetBytes(My.Resources.haarcascade_frontalface_alt2)

            Using stream As New MemoryStream(resourceBytes)

                If stream IsNot Nothing Then

                    ' Sauvegarder le stream dans un fichier temporaire
                    Using fileStream As New FileStream(tempFilePath, FileMode.Create, FileAccess.Write)
                        stream.CopyTo(fileStream)
                    End Using
                End If
            End Using
        End If

        Return New CascadeClassifier(tempFilePath)

Output:

Nothing, except for IIS services, it crashes because of access rights.

System.UnauthorizedAccessException: L'accès au chemin d'accès 'C:\Windows\SysWOW64
\inetsrv\haarcascade_frontalface_alt2.xml' est refusé.
 à System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
 à System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share,
Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean
useLongPath, Boolean checkHost)

What did you intend to be?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant