我是VB.net的新手,但我必須爲我們的項目執行此操作。我做了一個非常簡單的程序來調用我在vb.net中創建的matlab函數。這個程序很簡單,它只會確定圖片框中圖片的寬度和高度。在vb.net中使用MATLAB函數
這裏是我的MATLAB代碼,並使用.NET程序集導出一個.dll文件編譯它:
function [width, height, third] = imageInfo(input)
inImage = imread(input);
[width, height, third] = size(inImage);
end
這裏是我的程序的GUI:
而這裏的VB我做的代碼:
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
我總是得到一個錯誤,當r統一計劃。我希望你能用這個幫助我。謝謝
這將真正幫助,如果你能說你在說什麼類型的錯誤。這是一個例外嗎?它是否有消息?你什麼時候得到這個錯誤? – MPelletier
下面是錯誤的截圖:http://imagizer.imageshack.us/v2/800x600q90/819/yruy.jpg 我在運行程序時遇到了錯誤。 – elvinguitar