I'm new to VB.net but I have to do this for our project. I made a very simple program to call the matlab functions that I made in vb.net. This program is simple, it will just determine the width and the height of the image in the picturebox.
Here's my matlab code and compiled it using the .NET Assembly to export a .dll files:
function [width, height, third] = imageInfo(input)
inImage = imread(input);
[width, height, third] = size(inImage);
end
Here's the GUI of my program:
And here's the vb code that I made:
Imports MathWorks.MATLAB.NET.Arrays
Imports MathWorks.MATLAB.NET.Utility
Imports imageInfo
Public Class Form1
Public myImageInfo As New imageInfoClass
Dim imageWidth As String
Dim imageHeight As String
Dim result As New MWNumericArray
Dim imagePath As String
Private Sub btnBrowse_Click(sender As Object, e As EventArgs) Handles btnBrowse.Click
If ofdSelectPicture.ShowDialog = DialogResult.OK Then
pbImage.Image = Image.FromFile(ofdSelectPicture.FileName)
imagePath = "'" & ofdSelectPicture.FileName & "'"
End If
End Sub
Private Sub btnProcess_Click(sender As Object, e As EventArgs) Handles btnProcess.Click
result = myImageInfo.imageInfo(imagePath)
tbHeight.Text = imageHeight
tbWidth.Text = imageWidth
End Sub
End Class
I always got an error when running the program. I hope you can help me with this one. Thank you
This part here:
result = myImageInfo.imageInfo(imagePath)
imagePath
needs to be the full path. You strip it out and add commas with
imagePath = "'" & ofdSelectPicture.FileName & "'"
You can try:
imagePath = ofdSelectPicture.SafeFileName