Skip to content

Commit

Permalink
Merge pull request #18 from hjptriplebee/master
Browse files Browse the repository at this point in the history
update
  • Loading branch information
buyi1128 authored May 14, 2019
2 parents 25fe24c + a850b2d commit a21e8ec
Show file tree
Hide file tree
Showing 37 changed files with 694 additions and 32 deletions.
45 changes: 24 additions & 21 deletions Algorithm/pressure/digitPressure.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ def digitPressure(image, info):
heightSplit = info["heightSplit"]

# 将info中的参数加入代码中
# block = info["thresh"]["block"]
# type = info["thresh"]["type"]
# ifOpen = info["open"]
block = info["thresh"]["block"]
param = info["thresh"]["param"]
ifOpen = info["ifopen"]
# .........

# 由标定点得到液晶区域
Expand All @@ -36,7 +36,10 @@ def digitPressure(image, info):
Hist = cv2.equalizeHist(Blur)
thresh = cv2.adaptiveThreshold(Hist, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY_INV, 15, 11)
else:
thresh = cv2.adaptiveThreshold(gray, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 55, 11)
thresh = cv2.adaptiveThreshold(gray, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, block, param)
if ifOpen=="close":
p = cv2.getStructuringElement(cv2.MORPH_RECT, (2, 2))
res1 = cv2.morphologyEx(thresh, cv2.MORPH_CLOSE, p)

# 存储图片
if not os.path.exists("storeDigitData"):
Expand Down Expand Up @@ -75,28 +78,28 @@ def digitPressure(image, info):
img = thresh[heightSplit[i][0]:heightSplit[i][1], split[j]:split[j + 1]]
rgb_ = dst[heightSplit[i][0]:heightSplit[i][1], split[j]:split[j + 1]]
# 增强
kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (1, 2))
img = cv2.morphologyEx(img, cv2.MORPH_OPEN, kernel)
# kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (1, 2))
# img = cv2.morphologyEx(img, cv2.MORPH_OPEN, kernel)

num = MyNet.recognizeNet(img)
myNum = myNum + num

# 存储图片
cv2.imwrite("storeDigitData/thresh/{}/{}_{}{}_p{}.bmp".format(
num,
imgNum,
i,
j,
num
), img)

cv2.imwrite("storeDigitData/rgb/{}/{}_{}{}_p{}.bmp".format(
num,
imgNum,
i,
j,
num
), rgb_)
# cv2.imwrite("storeDigitData/thresh/{}/{}_{}{}_p{}.bmp".format(
# num,
# imgNum,
# i,
# j,
# num
# ), img)
#
# cv2.imwrite("storeDigitData/rgb/{}/{}_{}{}_p{}.bmp".format(
# num,
# imgNum,
# i,
# j,
# num
# ), rgb_)

myRes.append(myNum)

Expand Down
20 changes: 12 additions & 8 deletions TestServiceSample.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ def codecov(imgPath):
image = cv2.imread(imgPath + "/" + im)
print(im)
pos = im.split(".")[0].split("-")

for i in range(1, 6):
cfg = pos[0] + "-" + pos[1] + "_" + str(i)
if cfg + ".json" in config:
receive2 = meterReader(image, [cfg])
print(cfg, receive2)
cfg = im.split(".")[0]+"_1"
# for i in range(1, 6):
# cfg = pos[0] + "-" + pos[1] + "_" + str(i)
# if cfg + ".json" in config:
# receive2 = meterReader(image, [cfg])
# print(cfg, receive2)
receive2 = meterReader(image, [cfg])
print(cfg, receive2)
print("codecov done")


Expand Down Expand Up @@ -79,8 +81,10 @@ def testVideo():
# codecov("info/20190128/IMAGES/Pic_0226")
# codecov("info/20190128/IMAGES/video_")

codecov("info/20190410/IMAGES/Pic")
codecov("info/20190410/IMAGES/Pic_2")
# codecov("info/20190410/IMAGES/Pic")
# codecov("info/20190410/IMAGES/Pic_2")
codecov("info/20190514/image/")
codecov("info/20190514/image/")
#
# codecov("info/20190416/IMAGES/image")

Expand Down
7 changes: 4 additions & 3 deletions configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
# configPath = "info/20190128/config"
# templatePath = "info/20190128/template"
#
configPath = "info/20190410/config"
templatePath = "info/20190410/template"
# configPath = "info/20190410/config"
# templatePath = "info/20190410/template"

# configPath = "info/20190416/config"
# templatePath = "info/20190416/template"


configPath = "info/20190514/config"
templatePath = "info/20190514/template"


56 changes: 56 additions & 0 deletions info/20190514/config/10_1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "null",
"type": "digitPressure",
"ROI": {
"x": 578,
"y": 424,
"w": 361,
"h": 360
},
"startPoint": {
"x": 27,
"y": 45
},
"endPoint": {
"x": 71,
"y": 90
},
"centerPoint": {
"x": 69,
"y": 45
},
"startPointUp": {
"x": 0,
"y": 0
},
"endPointUp": {
"x": 0,
"y": 0
},
"centerPointUp": {
"x": 0,
"y": 0
},
"startValue": 0.0,
"totalValue": 0.0,
"digitType": "False",
"result": 0.0,
"rectangle": {
"width": 29,
"height": 30
},
"widthSplit": [
[1,28]
],
"heightSplit": [
[1,29]
],
"decimal":[
2
],
"thresh":{
"block":11,
"param":1
},
"ifopen":"close"
}
56 changes: 56 additions & 0 deletions info/20190514/config/11_1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "null",
"type": "digitPressure",
"ROI": {
"x": 694,
"y": 557,
"w": 177,
"h": 188
},
"startPoint": {
"x": 15,
"y": 36
},
"endPoint": {
"x": 59,
"y": 80
},
"centerPoint": {
"x": 60,
"y": 36
},
"startPointUp": {
"x": 0,
"y": 0
},
"endPointUp": {
"x": 0,
"y": 0
},
"centerPointUp": {
"x": 0,
"y": 0
},
"startValue": 0.0,
"totalValue": 0.0,
"digitType": "False",
"result": 0.0,
"rectangle": {
"width": 30,
"height": 30
},
"widthSplit": [
[1,29]
],
"heightSplit": [
[1,29]
],
"decimal":[
2
],
"thresh":{
"block":11,
"param":1
},
"ifopen":"close"
}
56 changes: 56 additions & 0 deletions info/20190514/config/12_1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "null",
"type": "digitPressure",
"ROI": {
"x": 606,
"y": 193,
"w": 430,
"h": 333
},
"startPoint": {
"x": 0,
"y": 0
},
"endPoint": {
"x": 0,
"y": 0
},
"centerPoint": {
"x": 0,
"y": 0
},
"startPointUp": {
"x": 0,
"y": 0
},
"endPointUp": {
"x": 0,
"y": 0
},
"centerPointUp": {
"x": 0,
"y": 0
},
"startValue": 0.0,
"totalValue": 0.0,
"digitType": "False",
"result": 0.0,
"rectangle": {
"width": 98,
"height": 30
},
"widthSplit": [
[1,14,26,38,50,63,75,87,97]
],
"heightSplit": [
[1,29]
],
"decimal":[
2
],
"thresh":{
"block":11,
"param":1
},
"ifopen":"close"
}
56 changes: 56 additions & 0 deletions info/20190514/config/13_1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "null",
"type": "digitPressure",
"ROI": {
"x": 639,
"y": 502,
"w": 88,
"h": 69
},
"startPoint": {
"x": 7,
"y": 6
},
"endPoint": {
"x": 32,
"y": 27
},
"centerPoint": {
"x": 32,
"y": 6
},
"startPointUp": {
"x": 0,
"y": 0
},
"endPointUp": {
"x": 0,
"y": 0
},
"centerPointUp": {
"x": 0,
"y": 0
},
"startValue": 0.0,
"totalValue": 0.0,
"digitType": "False",
"result": 0.0,
"rectangle": {
"width": 36,
"height": 30
},
"widthSplit": [
[1,35]
],
"heightSplit": [
[1,29]
],
"decimal":[
2
],
"thresh":{
"block":31,
"param":1
},
"ifopen":"close"
}
Loading

0 comments on commit a21e8ec

Please # to comment.