主题
获取密集矩形 - GetDenseRect
函数简介
查找二值化图片中像素最密集的区域,可以配合找色块等功能做二次分析。
接口名称
GetDenseRectDLL调用
c
int GetDenseRect(long instance, long image, int width, int height, int* x1, int* y1, int* x2, int* y2);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| image | 长整数型 | 图像句柄。 |
| width | 整数型 | 矩形宽度。 |
| height | 整数型 | 矩形高度。 |
| x1 | 整数型指针 | 返回左上角x坐标。 |
| y1 | 整数型指针 | 返回左上角y坐标。 |
| x2 | 整数型指针 | 返回右下角x坐标。 |
| y2 | 整数型指针 | 返回右下角y坐标。 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
long image = ola.LoadImage("maps/path_map.png");
if (image != 0) {
int x1, y1, x2, y2;
int ret = ola.GetDenseRect(image, 800, 600, x1, y1, x2, y2);
ola.FreeImage(image);
}csharp
using OLAPlug;
var ola = new OLAPlugServer();
long image = ola.LoadImage("maps/path_map.png");
if (image != 0)
{
int ret = ola.GetDenseRect(image, 800, 600, out int x1, out int y1, out int x2, out int y2);
ola.FreeImage(image);
}python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
image = ola.LoadImage("maps/path_map.png")
if image != 0:
ret, x1, y1, x2, y2 = ola.GetDenseRect(image, 800, 600)
ola.FreeImage(image)java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
long image = ola.LoadImage("maps/path_map.png");
if (image != 0) {
ola.GetDenseRect(image, 800, 600, 0, 0, 0, 0);
ola.FreeImage(image);
}cpp
var ola = com("OlaPlug.OlaSoft")
var image = ola.LoadImage("maps/path_map.png")
if(image) {
ola.GetDenseRect(image, 800, 600, 0, 0, 0, 0);
ola.FreeImage(image)
}vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
image = ola.LoadImage("maps/path_map.png")
If image <> 0 Then
ola.GetDenseRect(image, 800, 600, 0, 0, 0, 0);
ola.FreeImage(image)
End Iftext
.局部变量 ola, OLAPlug
ola.创建 ()
image = ola.LoadImage ("maps/path_map.png")
.如果真 (image ≠ 0)
ola.GetDenseRect(image, 800, 600, 0, 0, 0, 0);
ola.FreeImage (image)
.如果真结束aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var image = ola.LoadImage("maps/path_map.png");
if(image){
ola.GetDenseRect(image, 800, 600, 0, 0, 0, 0);
ola.FreeImage(image);
}text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
长整数 image = ola.LoadImage("maps/path_map.png")
如果真 (image ≠ 0)
{
ola.GetDenseRect(image, 800, 600, 0, 0, 0, 0);
ola.FreeImage(image)
}cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
long image = ola.LoadImage("maps/path_map.png");
if (image != 0) {
ola.GetDenseRect(image, 800, 600, 0, 0, 0, 0);
ola.FreeImage(image);
}原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
long image = LoadImage(instance, "maps/path_map.png");
if (image != 0) {
int x1, y1, x2, y2;
int ret = ola.GetDenseRect(image, 800, 600, x1, y1, x2, y2);
FreeImage(instance, image);
}csharp
using System.Runtime.InteropServices;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
long instance = CreateCOLAPlugInterFace();
long image = LoadImage(instance, "maps/path_map.png");
if (image != 0) {
int ret = ola.GetDenseRect(image, 800, 600, out int x1, out int y1, out int x2, out int y2);
FreeImage(instance, image);
}python
from ctypes import CDLL, c_int, c_int64
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
image = ola.LoadImage(instance, b"maps/path_map.png")
if image:
ret, x1, y1, x2, y2 = ola.GetDenseRect(image, 800, 600)
ola.FreeImage(instance, image)返回值
| 返回值 | 说明 |
|---|---|
1 | 成功。 |
0 | 失败。 |
