Skip to content

CascadeClassifier constructor #1730

@paredominic

Description

@paredominic

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions