Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Yaxi pressure gage #7

Merged
merged 3 commits into from
Dec 19, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Yaxi pressure gage
  • Loading branch information
buyi1128 committed Dec 19, 2018
commit 7182d52cb2ffdd66ec6ca3fd3e6755458335bdff
3 changes: 0 additions & 3 deletions Interface.py
Original file line number Diff line number Diff line change
@@ -75,6 +75,3 @@ def meterReader(image, meterIDs):
# call back
results[ID] = meterReaderCallBack(ROI, info)
return results

# image = cv2.imread("image/pressure.jpg")
# print(meterReader(image, ["pressure"]))
22 changes: 13 additions & 9 deletions pressure.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from Common import *

import math
import numpy as np


def pressure(image, info):
"""
:param image: ROI image
@@ -27,18 +25,16 @@ def pressure(image, info):
center = np.array([info["centerPoint"]["x"], info["centerPoint"]["y"]])
totalvalue = info["totalValue"]
startvalue = info["startValue"]
# print("start: ", start, " end:", end, " center:", center)
# print("pointer:", pointer)
# print(startvalue, totalvalue)
result = AngleFactory.calPointerValueByPointerVector(start, end, center, pointer, startvalue, totalvalue)
print("result: ", result)

return result




def getLine(img):
"""
draw pointer line on the image
:param img:
:return: first detected line
"""
img = cv2.GaussianBlur(img, (3, 3), 0)
# cv2.imshow("GaussianBlur ", img)
edges = cv2.Canny(img, 100, 200, apertureSize=3)
@@ -66,6 +62,14 @@ def getLine(img):


def getPointer(x0, y0, width, height):
"""
limit line in the image
:param x0:
:param y0:
:param width: image width
:param height: image height
:return: two point of the detected line
"""
xcenter = int(width / 2)
ycenter = int(height / 2)
if xcenter < x0 or (xcenter == x0 and ycenter > y0):