quick_find

<span style="font-family:SimSun;font-size:10px;">#include<stdio.h></span>
<span style="font-family:SimSun;font-size:10px;">#define MAXVEX 100</span>

int id[MAXVEX];
int N;

void create_array(int n)
{
	int i;
	//初始化id集合
	for( i=0;i<n;++i)
	{
		id[i]=i;
	}	
}

void quick_union(int p,int q)
{
	int i;
	int pid=id[p];
	int qid=id[q];
	for(i=0; i<N; i++)
	{
		if(id[i] == pid)
			id[i] = qid;
	}
}
int connected(int p,int q)
{
	return id[p] == id[q];
}
void display(int N)
{
	int i;
	for(i=0;i<N;++i)
		printf("id[%d]:%d \n",i,id[i]);
}

void main()
{
	N=10;
	create_array(N);

	quick_union(0,1);
	quick_union(8,9);
	quick_union(4,5);
	quick_union(5,1);
	display(10);
	if(connected(3,4))
		printf("id[3] is connected to id[4]\n");
	else
		printf("id[3] isn't connected to id[4]\n");
	if(connected(4,5))
		printf("id[4] is connected to id[5]\n");
	else
		printf("not connected\n");
	
}




                
这个方法中形参loc=5,为什么置灰似乎没有调用,请帮我分析这个方法: def checkImage(self, src_path, similar=0.95, loc=5, debug=False): """ 检测当前屏幕是否存在目标图片(基于图像匹配) :param src_path: 目标图片路径(相对或绝对路径) :param similar: 相似度阈值(0-1之间,默认0.95) :param loc: 匹配位置参数(具体含义依赖ImgUtils.quick_find实现) :param debug: 是否开启调试模式(默认False) :return: 布尔值(True:找到目标图片;False:未找到) """ # 步骤1:获取当前屏幕截图路径 screenshot_dir = os.path.join(os.getcwd(), "resource/superapp") os.makedirs(screenshot_dir, exist_ok=True) current_screenshot_path = os.path.join(screenshot_dir, "test.png") # 步骤2:校验目标图片是否存在 resource_root = os.path.join(os.getcwd(), "resource", "superapp") target_image_path = os.path.join(resource_root, src_path) if not os.path.isfile(target_image_path): print(f"{src_path}不存在!!!") # 步骤3:校验截图文件是否有效 if not os.path.exists(current_screenshot_path) or not os.path.isfile(current_screenshot_path): print(f"{current_screenshot_path}无效!!!") # 步骤4:校验相似度阈值有效性 if not 0 <= similar <= 1: raise ValueError(f"相似度阈值必须在0到1之间,当前值:{similar}") try: # 步骤5:调用图片匹配算法(返回匹配坐标和匹配得分) match_position, match_score = self.quick_find( current_screenshot_path, target_image_path, similar=similar, loc="all", debug=debug ) print(f"匹配结果-坐标:{match_position},得分:{match_score}") # 步骤6:判定是否匹配成功(坐标和得分均不为None) is_matched = (match_position is not None) and (match_score is not None) print(f"匹配结果:{is_matched}") return is_matched except Exception as e: print(f"图片匹配异常:{str(e)}") return False
07-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值