画像から行列への複写
Namespace: fvalgcliAssembly: fvalgcli (in fvalgcli.dll) Version: 3.1.0.0 (3.1.0.11)
Syntax
C# |
---|
public static int fnFIE_mat_copy_from_img(
FHANDLE hsrc,
FMATRIX_PTR a
) |
Visual Basic |
---|
Public Shared Function fnFIE_mat_copy_from_img (
hsrc As FHANDLE,
a As FMATRIX_PTR
) As Integer |
Return Value
Type:
Int32
以下のエラーコードを返します。
エラーコード:f_err | 内容 |
---|
F_ERR_NONE | 正常終了 |
F_ERR_INVALID_PARAM | パラメータ不正 |
F_ERR_INVALID_IMAGE | 不正な画像エラー |
F_ERR_NO_LICENCE | ライセンスエラー、または未初期化エラー |
Examples
C# | Copy |
---|
using System;
using System.Collections.Generic;
using System.Text;
using fvalgcli;
namespace TC
{
public partial class FIE
{
[FvPluginExecute]
public void fnFIE_mat_copy_from_img()
{
FHANDLE hsrc = FHANDLE.Zero;
FMATRIX_PTR a = FMATRIX_PTR.Zero;
try
{
const int height = 4;
const int width = 3;
hsrc = api.fnFIE_img_root_alloc(f_imgtype.F_IMG_UC8, 1, width, height);
a = api.fnFIE_mat_aalloc(height, width);
Assert.IsTrue(hsrc != FHANDLE.Zero, "エラーが発生しました。");
Assert.IsTrue(a != FMATRIX_PTR.Zero, "エラーが発生しました。");
UCHAR_PTR psrc = api.fnFIE_img_get_adrs(hsrc);
SIZE_T stride = api.fnFIE_img_get_step_as_bytes(hsrc);
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
psrc[x] = (byte)(y * 10 + x);
}
psrc = psrc + stride;
}
int status = api.fnFIE_mat_copy_from_img(hsrc, a);
Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "エラーが発生しました。({0})", (f_err)status);
for (int y = 0; y < height; y++)
{
Console.Write("[{0}]", y);
for (int x = 0; x < width; x++)
{
Console.Write(" {0,2:F0}", a[y, x]);
}
Console.WriteLine("");
}
}
finally
{
hsrc.Dispose();
a.Dispose();
}
}
}
} |
Visual Basic | Copy |
---|
Imports System.Collections.Generic
Imports System.Text
Imports fvalgcli
Public Partial Class FIE
<FvPluginExecute> _
Public Sub fnFIE_mat_copy_from_img()
Dim hsrc As FHANDLE = FHANDLE.Zero
Dim a As FMATRIX_PTR = FMATRIX_PTR.Zero
Try
Const height As Integer = 4
Const width As Integer = 3
hsrc = api.fnFIE_img_root_alloc(f_imgtype.F_IMG_UC8, 1, width, height)
a = api.fnFIE_mat_aalloc(height, width)
Assert.IsTrue(hsrc <> FHANDLE.Zero, "エラーが発生しました。")
Assert.IsTrue(a <> FMATRIX_PTR.Zero, "エラーが発生しました。")
Dim psrc As UCHAR_PTR = api.fnFIE_img_get_adrs(hsrc)
Dim stride As SIZE_T = api.fnFIE_img_get_step_as_bytes(hsrc)
For y As Integer = 0 To height - 1
For x As Integer = 0 To width - 1
psrc(x) = CByte(y * 10 + x)
Next
psrc = psrc + stride
Next
Dim status As Integer = api.fnFIE_mat_copy_from_img(hsrc, a)
Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "エラーが発生しました。({0})", CType(status, f_err))
For y As Integer = 0 To height - 1
Console.Write("[{0}]", y)
For x As Integer = 0 To width - 1
Console.Write(" {0,2:F0}", a(y, x))
Next
Console.WriteLine("")
Next
Finally
hsrc.Dispose()
a.Dispose()
End Try
End Sub
End Class |
See Also