如果在“COM_IDL_connectLib.COM_IDL_connect oComIDL = new COM_IDL_connectLib.COM_IDL_connect();”步骤提示“...80040154没有注册类...”,则需要在管理员权限下利用regsvr32命令注册“...\Exelis\IDL85\resource\bridges\export\COM\COM_idl_connect.dll”组件,如下图:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace FloodMonitor
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Button1_Click(object sender, MouseEventArgs e)
{ //新建COM_IDL_CONNECT对象
COM_IDL_connectLib.COM_IDL_connect oComIDL = new COM_IDL_connectLib.COM_IDL_connect();
//对象初始化————必不可少
oComIDL.CreateObject(0, 0, 0);
string infile = @"G:\Temp\应用示范子系统\Flood\S1A_IW_GRDH_1SDV_20180907T100312_20180907T100337_023591_0291E9_9B89_Cal_EC_Sub4.dat";
string outfile = @"G:\Temp\应用示范子系统\Flood\S1A_IW_GRDH_1SDV_20180907T100312_20180907T100337_023591_0291E9_9B89_Cal_EC_Sub4_Water.dat";
string tempfile = @"G:\Temp\应用示范子系统\Flood\S1A_IW_GRDH_1SDV_20180907T100312_20180907T100337_023591_0291E9_9B89_Cal_EC_Sub4_PCA2.dat";
oComIDL.ExecuteString(".compile E:\\IDLWORK_8.5\\Application_Demonstration\\source\\FloodMonitor.pro");
//执行主成分分析
oComIDL.ExecuteString("ret = FloodMonitor('" + infile + "','" + tempfile + "', error=error)");
object objRet1 = oComIDL.GetIDLVariable("ret");
string ret1 = objRet1.ToString();
if (String.Equals(ret1, "1"))
{
MessageBox.Show("主成分分析完成!");
}
else
{
object objError = oComIDL.GetIDLVariable("error");
string error = objError.ToString();
MessageBox.Show("主成分分析失败!" + error);
}
//设置阈值
string threshold = "4.95";
//阈值分割
oComIDL.ExecuteString("ret = FloodMonitor_GetFlood('" + tempfile + "'," + threshold + ",'" + outfile + "')");
object objRet2 = oComIDL.GetIDLVariable("ret");
string ret2 = objRet2.ToString();
if (String.Equals(ret2, "1"))
{
MessageBox.Show("洪水覆盖范围提取完成!");
}
else
{
object objError = oComIDL.GetIDLVariable("error");
string error = objError.ToString();
MessageBox.Show("洪水覆盖范围提取失败!" + error);
}
oComIDL.DestroyObject();
}
}
}
|
请发表评论