GetIntValue("in1",ref size); float[] BLOB = new float[size]; int[] BLOB1 = new int[size]; GetIntValue("in1",ref S); SetIntValue("out0",S); GetFloatArrayValue("in0",ref BLOB,out S); GetIntArrayValue("in4",ref BLOB1,out S); SetFloatArrayValue("out1",BLOB,0,S); GetFloatValue("in2",ref MIN); GetFloatValue("in3",ref MAX); R1 = 0; R2 = 0; R3 = 0; R4 = 0; R5 = 0; //R3 = BLOB.Count(x => x != 0); //R4 = BLOB1.Count(x => x != 0); for(int i = 0 ; i < S ;i++) { if(BLOB[i]> MAX) { R1++; } if(BLOB[i]< MIN) { R2++; } if(BLOB[i] != 0) { R3++; } if(BLOB1[i] != 0) { R4++; } } //长轴太长太短短数据统计 if((R1>=1||R2>=1 ) && (R4>=size/2)) { res=2; } else { res=1; } SetIntValue("out1",res); SetIntValue("out2",R3); SetIntValue("out3",R4); return true; } } 为什么res还是1
时间: 2024-02-14 15:22:26 浏览: 22
根据代码中的逻辑,如果存在长轴太长或太短的数据并且非零元素个数超过数组大小一半,则将res设为2,否则将res设为1。因此,如果在数组BLOB和BLOB1中存在长轴太长或太短的数据,但非零元素个数不足数组大小一半,那么res将保持为1。也就是说,res的值只与数组中非零元素个数是否超过数组大小一半有关,与长轴太长或太短的数据的具体情况无关。
相关问题
float[] BLOB = new float[size]; int[] BLOB1 = new int[size]; GetIntValue("in1",ref S); SetIntValue("out0",S); GetFloatArrayValue("in0",ref BLOB,out S); GetIntArrayValue("in4",ref BLOB1,out S); SetFloatArrayValue("out1",BLOB,0,S); GetFloatValue("in2",ref MIN); GetFloatValue("in3",ref MAX); R1 = 0; R2 = 0; R3 = 0; R4 = 1; R5 = 0; for(int i = 0 ; i < S ;i++) { if(BLOB[i]> MAX) { R1++; } if( BLOB[i]< MIN) { R2++; } }//长轴太长太短短数据统计 for(int i = 0 ; i < S ;i++) { if(BLOB[i]>0) { R3++; } }//长轴长短数据统计 for(int i = 0 ; i < S ;i++) { if(BLOB1[i]>=0) { R4++; } }//BLOB模块数据计数 //R3=R3+1;默认统计时为0开始,所以需要+1 //R4=R4默认统计时为0开始,所以需要+1 if(R1>=1||R2>=1 ) { res=2; } else { res=1; } SetIntValue("out1",res); SetIntValue("out2",R3); SetIntValue("out3",R4); return true; } }
这段代码看起来像是 C# 或者类似的语言写的,它是用来处理一个输入 BLOB 和一些数字的统计和判断逻辑。具体来说,它会从输入中读取一个 float 数组和一个 int 数组,以及四个 float 类型的数字,然后进行一些计算和判断,最终将结果输出到四个 int 类型的变量中。其中,如果 BLOB 中有任何一个元素小于 MIN 或者大于 MAX,那么结果将为 2,否则结果为 1。同时,它还会统计 BLOB 中大于 0 的元素个数和 BLOB1 中大于等于 0 的元素个数,并将它们输出到两个变量中。
cam.MV_CC_GetIntValue("PayloadSize", stParam)解释
这是一个针对机器视觉相机的调用,用于获取图像数据的有效负载大小。其中,cam是指相机对象,MV_CC_GetIntValue是获取相机参数值的方法,"PayloadSize"是指相机参数的名称,stParam是用于返回获取的参数值的结构体。该方法的作用是获取相机中图像数据的大小,以便在程序中分配合适大小的内存用于存储图像数据。
相关推荐
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)