|
@@ -6,12 +6,22 @@ from OptionExcel import COptionExcel
|
|
|
from OptionConfig import COptionConfig
|
|
|
from OptionAction import COptionAction
|
|
|
from ssat_sdk.source_input import SourceGenInput
|
|
|
+from ssat_sdk.tv_detect import *
|
|
|
+from ssat_sdk.device_manage.capturecard_manager import CCardManager
|
|
|
# 测试使用到
|
|
|
import random
|
|
|
|
|
|
|
|
|
class CTMenu(CBaseLog):
|
|
|
sourceInput = SourceGenInput()
|
|
|
+ # 红老鼠遥控对象;
|
|
|
+ redRat3 = TvOperator()
|
|
|
+ # 创建视频采集对象
|
|
|
+ captureCard = CCardManager()
|
|
|
+ # 图片切割对象
|
|
|
+ imgCMP = ImageCMP()
|
|
|
+ rgbColor = RGBColor()
|
|
|
+ CIE = CIEluvCaculator()
|
|
|
|
|
|
def __init__(self, ocrDict=None):
|
|
|
CBaseLog.__init__(self)
|
|
@@ -19,6 +29,10 @@ class CTMenu(CBaseLog):
|
|
|
self.__optionExcel = COptionExcel(self.__exData)
|
|
|
self.__optionConfig = COptionConfig(self.__exData, self.__optionExcel)
|
|
|
|
|
|
+ @property
|
|
|
+ def exData(self):
|
|
|
+ return self.__exData
|
|
|
+
|
|
|
@property
|
|
|
def optionExcel(self):
|
|
|
return self.__optionExcel
|
|
@@ -27,6 +41,13 @@ class CTMenu(CBaseLog):
|
|
|
def optionConfig(self):
|
|
|
return self.__optionConfig
|
|
|
|
|
|
+ def takePicture(self):
|
|
|
+ img = os.path.join(getSATTmpDIR(), "menutree_runpath.png")
|
|
|
+ self.captureCard.takePicture(img)
|
|
|
+ if not os.path.exists(img):
|
|
|
+ self.error(u"截图失败:%s" % img)
|
|
|
+ return img
|
|
|
+
|
|
|
'''
|
|
|
函数:判断两值(for_ocr与ocr识别结果)是否相等;
|
|
|
参数:
|
|
@@ -343,8 +364,52 @@ class CTMenu(CBaseLog):
|
|
|
参数:
|
|
|
返回:
|
|
|
'''
|
|
|
- def watchOption(self):
|
|
|
- pass
|
|
|
+ def checkChannelList(self, channelList, maxTry=15):
|
|
|
+ failChannelList = []
|
|
|
+ checkResult = True
|
|
|
+ if not channelList:
|
|
|
+ self.error(u"传入的待检测的频道列表为空!")
|
|
|
+ return False, failChannelList
|
|
|
+ for channel in channelList:
|
|
|
+ isSearched = self.checkOptionValue("ok", channel)
|
|
|
+ if not isSearched:
|
|
|
+ self.warn(u"频道:%s查找失败!" % str(channel))
|
|
|
+ failChannelList.append(channel)
|
|
|
+ checkResult = False
|
|
|
+ # 部分机芯项目(如6586外协松下)按return键无法退出频道,故改为exit键
|
|
|
+ # self.redRat3.sendKey("return")
|
|
|
+ self.redRat3.sendKey("exit")
|
|
|
+ else:
|
|
|
+ self.info(u"频道:%s查找成功!" % str(channel))
|
|
|
+ self.redRat3.sendKey("exit")
|
|
|
+ self.info(u"频道列表检测结果checkResult:%s,检测失败频道列表failChannelLis:%s" % (str(checkResult), str(failChannelList)))
|
|
|
+ return checkResult, failChannelList
|
|
|
+
|
|
|
+ '''
|
|
|
+ 函数:
|
|
|
+ 参数:
|
|
|
+ 返回:
|
|
|
+ '''
|
|
|
+ def getBlackChannel(self, channelCount, blackThreshold=20, blackRate=2.0):
|
|
|
+ result = False
|
|
|
+ # 根据频道数量遍历;
|
|
|
+ for i in range(0, channelCount):
|
|
|
+ # 截图,取左半边;
|
|
|
+ pic_path = self.takePicture()
|
|
|
+ img = cv.imread(pic_path)
|
|
|
+ pic_path2 = os.path.join(getSATTmpDIR(), "menutree_focus_area_half.png")
|
|
|
+ self.imgCMP.saveCropPic(pic_path, pic_path2, (0, 0, img.shape[1] / 2, img.shape[0]))
|
|
|
+ # 是否符合要求;
|
|
|
+ result = self.imgCMP.isBlack(pic_path2, blackThreshold, 10, 1 - blackRate)
|
|
|
+ if result is True:
|
|
|
+ break
|
|
|
+
|
|
|
+ # 下一频道号;
|
|
|
+ self.redRat3.sendKey('C+')
|
|
|
+ time.sleep(4)
|
|
|
+ # endfor
|
|
|
+
|
|
|
+ return result
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
@@ -502,6 +567,7 @@ if __name__ == "__main__":
|
|
|
time.sleep(st)
|
|
|
ml.getOptionValue('picture_preset')
|
|
|
|
|
|
+ ml.getBlackChannel(10)
|
|
|
if 1:
|
|
|
ml.openOption('picture')
|
|
|
ml.moveToOption('brightness')
|