Reputation: 74
I got above error after copying and pasting some code
from here, github.
Will you guys help me to fix it? my code:
Imports Emgu.CV 'usual Emgu Cv imports
Imports Emgu.CV.CvEnum '
Imports Emgu.CV.Structure '
Imports Emgu.CV.UI
Public Class frmMain
Private Sub btnOpenFile_Click(sender As Object, e As EventArgs) Handles btnOpenFile.Click
The LoadImageType
gives me some suggestions, I tried but didn't get helpful.
imgOriginal = New Mat(ofdOpenFile.FileName, LoadImageType.Color)
Catch ex As Exception
CvInvoke.GaussianBlur(imgGrayscale, imgBlurred, New Size(5, 5), 1.5)
CvInvoke.Canny(imgBlurred, imgCanny, 100, 200)
ibOriginal.Image = imgOriginal 'update image boxes
ibCanny.Image = imgCanny '
End Sub
End Class
Upvotes: 1
Views: 835
Reputation: 39
Simply replace
LoadImageType.Color
with:
CType(1, ImreadModes)
As said by Jurjen, it's an integer only, BUT comes from the ImreadModes
enum.
Upvotes: 0
Reputation: 1396
I notice you created your own class called LoadImageType.vb
. However, LoadImageType
is already a OpenCV enum
. You get this error because you probably don't refer to this class at all or you don't initialize it (see also this link).
I would recommend you to remove this custom class that you created and use the OpenCV enum
. This enum
is located in the Emgu.CV.CvEnum
namespace. Maybe specifically specify you want to use the CVEnum
namespace:
imgOriginal = New Mat(ofdOpenFile.FileName, CvEnum.LoadImageType.Color)
'You can even try this
imgOriginal = New Mat(ofdOpenFile.FileName, Emgu.CV.CvEnum.LoadImageType.Color)
If this doesn't work, why don't you try to see if you can specifically enter a integer? The LoadImageType
enum is nothing else then a conversion to a integer (see docs). So for color, you should enter value 1
. If this works, you know something goes wrong with using the enumeration:
imgOriginal = New Mat(ofdOpenFile.FileName, 1)
If this still doesn't work, why don't you just use the imread
method (see docs)? I always use that one without a LoadImageType enum
and have no problems at all:
Dim img As Mat
img = CvInvoke.Imread(ofdOpenFile.FileName)
Or if you specifically want to use LoadImageType
you can also try:
Dim img As Mat
img = CvInvoke.Imread(ofdOpenFile.FileName, CvEnum.LoadImageType.Color)
Upvotes: 0