Преглед изворни кода

v0.8.4 叶子遮挡识别优化:小叶遮挡,茎没有识别出来,植株误判问题

chenhongjiang пре 1 година
родитељ
комит
3a119c2afd
4 измењених фајлова са 14 додато и 12 уклоњено
  1. 2 1
      ReadMe.txt
  2. 8 8
      grab_point_rs.cpp
  3. 3 2
      grab_point_rs.h
  4. 1 1
      graft_cv_api.cpp

+ 2 - 1
ReadMe.txt

@@ -112,4 +112,5 @@ v0.7.23 识
 v0.8.0 叶子遮挡识别;去除原来图片识别的内容;修改配置参数仅保留3d相关参数
 v0.8.0 叶子遮挡识别;去除原来图片识别的内容;修改配置参数仅保留3d相关参数
 v0.8.1 叶子遮挡识别优化:通过x截取范围和穴位个数直接确定茎根中心位置
 v0.8.1 叶子遮挡识别优化:通过x截取范围和穴位个数直接确定茎根中心位置
 v0.8.2 叶子遮挡识别优化:用叶子点云数量判断是否有遮挡,加上识别的茎的位置,统计植株的个数
 v0.8.2 叶子遮挡识别优化:用叶子点云数量判断是否有遮挡,加上识别的茎的位置,统计植株的个数
-v0.8.3 叶子遮挡识别优化:解决叶子遮挡不计数问题;修改点云密度计算方法
+v0.8.3 叶子遮挡识别优化:解决叶子遮挡不计数问题;修改点云密度计算方法
+v0.8.4 叶子遮挡识别优化:小叶遮挡,茎没有识别出来,植株误判问题

+ 8 - 8
grab_point_rs.cpp

@@ -679,7 +679,9 @@ obstructed:
 		pcl::PointCloud<pcl::PointXYZ>::Ptr in_cloud,	//input 输入点云数据			
 		pcl::PointCloud<pcl::PointXYZ>::Ptr in_cloud,	//input 输入点云数据			
 		std::vector<int>& leaf_idx
 		std::vector<int>& leaf_idx
 	)
 	)
-	{		
+	{	
+		//仅用叶子点云数量,有时会出现因叶子误识别(和ror_ratio相关),造成叶子点云数量小,造成误判
+		//所以改成整个空间点云数量做判别--2024-3-2
 		m_root_center_with_seedling.clear();
 		m_root_center_with_seedling.clear();
 		m_root_center_with_seedling.assign(m_root_centers.size(), false);
 		m_root_center_with_seedling.assign(m_root_centers.size(), false);
 		std::vector<int> pcd_cnt;
 		std::vector<int> pcd_cnt;
@@ -694,13 +696,13 @@ obstructed:
 			y_min = m_cparam.sc_grab_ymin;
 			y_min = m_cparam.sc_grab_ymin;
 			y_max = m_cparam.sc_grab_ymax;
 			y_max = m_cparam.sc_grab_ymax;
 		}
 		}
-		int th_pcd_size = stem_diameter * (y_max - y_min) / m_cloud_mean_dist / m_cloud_mean_dist;
+		int th_pcd_size = 0.333 * stem_diameter * (y_max - y_min) / m_cloud_mean_dist / m_cloud_mean_dist;
 		std::vector<pcl::PointXYZ> aabb_mins_maxs;		
 		std::vector<pcl::PointXYZ> aabb_mins_maxs;		
 		for (int i = 0; i < m_root_centers.size(); ++i) {
 		for (int i = 0; i < m_root_centers.size(); ++i) {
 			CStemResult& rc = m_root_centers.at(i);
 			CStemResult& rc = m_root_centers.at(i);
 			pcl::PointXYZ aabb_min;
 			pcl::PointXYZ aabb_min;
 			pcl::PointXYZ aabb_max;
 			pcl::PointXYZ aabb_max;
-			int cnt = get_point_count_inbox(rc, aabb_min, aabb_max, in_cloud, leaf_idx);
+			int cnt = get_point_count_inbox(rc, aabb_min, aabb_max, in_cloud);
 			pcd_cnt.push_back(cnt);			
 			pcd_cnt.push_back(cnt);			
 			bool has_seedling = cnt > th_pcd_size;
 			bool has_seedling = cnt > th_pcd_size;
 			m_root_center_with_seedling.at(i) = has_seedling;
 			m_root_center_with_seedling.at(i) = has_seedling;
@@ -774,8 +776,8 @@ obstructed:
 	int CRootStockGrabPoint::get_point_count_inbox(const CStemResult& sr,
 	int CRootStockGrabPoint::get_point_count_inbox(const CStemResult& sr,
 		pcl::PointXYZ& aabb_min,
 		pcl::PointXYZ& aabb_min,
 		pcl::PointXYZ& aabb_max,
 		pcl::PointXYZ& aabb_max,
-		pcl::PointCloud<pcl::PointXYZ>::Ptr in_cloud,	//input 输入点云数据			
-		std::vector<int>& leaf_idx)
+		pcl::PointCloud<pcl::PointXYZ>::Ptr in_cloud	//input 输入点云数据			
+		)
 	{
 	{
 		double seedling_distance = m_cparam.rs_grab_seedling_dist;
 		double seedling_distance = m_cparam.rs_grab_seedling_dist;
 		double min_y = m_cparam.rs_grab_ymin;
 		double min_y = m_cparam.rs_grab_ymin;
@@ -791,9 +793,7 @@ obstructed:
 		double max_z = sr.root_z + 0.25 * seedling_distance;		
 		double max_z = sr.root_z + 0.25 * seedling_distance;		
 
 
 		int count = 0;
 		int count = 0;
-		//for (auto&pt : m_raw_cloud->points) {
-		for (auto&i : leaf_idx) {
-			pcl::PointXYZ& pt = in_cloud->points.at(i);
+		for (auto&pt : in_cloud->points) {			
 			if (pt.y >= min_y && pt.y <= max_y &&
 			if (pt.y >= min_y && pt.y <= max_y &&
 				pt.x >= min_x && pt.x <= max_x &&
 				pt.x >= min_x && pt.x <= max_x &&
 				pt.z >= min_z && pt.z <= max_z)
 				pt.z >= min_z && pt.z <= max_z)

+ 3 - 2
grab_point_rs.h

@@ -29,6 +29,7 @@ namespace graft_cv {
 		CStemResultInfos* m_pStemInfos;
 		CStemResultInfos* m_pStemInfos;
 		std::string m_stem_info_file;
 		std::string m_stem_info_file;
 		std::vector<CStemResult> m_root_centers;  //通过m_pStemInfos获取到历史根中心位置
 		std::vector<CStemResult> m_root_centers;  //通过m_pStemInfos获取到历史根中心位置
+		std::vector<int> m_root_center_pcd_size;
 		std::vector<bool> m_root_center_with_seedling;	//m_root_centers位置上是否含有植株
 		std::vector<bool> m_root_center_with_seedling;	//m_root_centers位置上是否含有植株
 
 
 		//用于记录第一排z均值,用来辅助判别1、2排的苗
 		//用于记录第一排z均值,用来辅助判别1、2排的苗
@@ -183,8 +184,8 @@ namespace graft_cv {
 		int get_point_count_inbox(const CStemResult& sr, //input
 		int get_point_count_inbox(const CStemResult& sr, //input
 			pcl::PointXYZ& aabb_min,	//output
 			pcl::PointXYZ& aabb_min,	//output
 			pcl::PointXYZ& aabb_max,	//output
 			pcl::PointXYZ& aabb_max,	//output
-			pcl::PointCloud<pcl::PointXYZ>::Ptr in_cloud,	//input 输入点云数据			
-			std::vector<int>& leaf_idx);
+			pcl::PointCloud<pcl::PointXYZ>::Ptr in_cloud	//input 输入点云数据			
+			);
 		//没有检测到苗的情况,后处理
 		//没有检测到苗的情况,后处理
 		void no_seedling_detected_post_process(
 		void no_seedling_detected_post_process(
 			int first_row_seedling_number,		//input
 			int first_row_seedling_number,		//input

+ 1 - 1
graft_cv_api.cpp

@@ -15,7 +15,7 @@ extern CRITICAL_SECTION g_cs;
 namespace graft_cv
 namespace graft_cv
 {
 {
 
 
-	char *g_version_str = "0.8.3";
+	char *g_version_str = "0.8.4";
 
 
 	//configure
 	//configure
 	string g_conf_file = "./gcv_conf.yml";	
 	string g_conf_file = "./gcv_conf.yml";