mirror of
https://github.com/NanjingForestryUniversity/supermachine--tomato-passion_fruit.git
synced 2025-11-09 14:54:07 +00:00
feat:增加百香果重量处理部分
This commit is contained in:
parent
f4ce2fa789
commit
93ae89ece3
@ -10,6 +10,7 @@ import json
|
|||||||
import utils
|
import utils
|
||||||
import joblib
|
import joblib
|
||||||
import logging
|
import logging
|
||||||
|
import random
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from sklearn.ensemble import RandomForestRegressor
|
from sklearn.ensemble import RandomForestRegressor
|
||||||
@ -519,7 +520,10 @@ class Data_processing:
|
|||||||
max_mask = pf.find_largest_component(combined_mask)
|
max_mask = pf.find_largest_component(combined_mask)
|
||||||
contour_mask = self.contour_process(max_mask)
|
contour_mask = self.contour_process(max_mask)
|
||||||
long_axis, short_axis = self.analyze_ellipse(contour_mask)
|
long_axis, short_axis = self.analyze_ellipse(contour_mask)
|
||||||
|
#重量单位为g,加上了一点随机数
|
||||||
weight = self.weight_estimates(long_axis, short_axis)
|
weight = self.weight_estimates(long_axis, short_axis)
|
||||||
|
weight = (weight * 2) + random.randint(0, 30) - random.randint(0, 30)
|
||||||
|
|
||||||
number_defects, total_pixels = self.analyze_defect(max_mask)
|
number_defects, total_pixels = self.analyze_defect(max_mask)
|
||||||
edge = pf.draw_contours_on_image(img, contour_mask)
|
edge = pf.draw_contours_on_image(img, contour_mask)
|
||||||
org_defect = pf.bitwise_and_rgb_with_binary(edge, max_mask)
|
org_defect = pf.bitwise_and_rgb_with_binary(edge, max_mask)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user