Beispiel #1
0
 def __init__(self, seed=None):
     env = gym.make("Pendulum-v0")
     self._forceScale = env.action_space.high
     super().__init__(
         ENV.ProcessedStateEnv(ENV.GymEnvironment(env, seed=seed),
                               processor=self._processState))
     return
Beispiel #2
0
    def initRules(self):
        self.initOCRRules()
        self.initVisionRules()
        self.mIndex = int( Environment.getValue(Environment.KEY_RULE_FILTER_INDEX))
        if (self.mIndex == None or self.mIndex < 0):
            return
        
        # mIndex = 0, 1, 2
        if self.mIndex < len(self.mVisionRules):
            self.mVisionRules.remove(int (self.mIndex))
#            System.out.println("The rule is removed (vision), total: "
#                    + (mVisionRules.size()) + ": " + mIndex);
#            // mIndex = 3, 4, 5 ...
        elif self.mIndex - len(self.mVisionRules.size()) < len(self.mOCRRules):

           self.mOCRRules.remove(self.mIndex - len(self.mVisionRules))
    def updateManifestFile(self, orientation):

        #		@SuppressWarnings("unchecked")
        selectNode = self.mDocument.find('application')
        selectNodes = selectNode.findall('activity')

        if (Environment.getValue(Environment.KEY_WITH_TITLE_BAR) == False):
            #			 change theme
            for node in selectNodes:
                #                element = Element(node)
                node.set("android:theme",
                         "@android:style/Theme.Black.NoTitleBar")
#		// change orientation
        if (orientation == LayoutHelper.ORIENTATION_LANDSCAPE):
            for node in selectNodes:
                #                element = Element(node)
                node.set("android:screenOrientation", "landscape")
    def __init__(self, rgbaImage, profile):
#        if profile == None: 
#            profile =  Profile("Nexus 5", Calculator.XXHDPI, Constants.DEFAULT_OUTPUT_SCREEN_WIDTH_PIXEL, Constants.DEFAULT_OUTPUT_SCREEN_HEIGHT_PIXEL,Constants.DEFAULT_SCREEN_WIDTH_DP, Constants.DEFAULT_SCREEN_CONTENT_VIEW_HEIGHT_DP, Constants.DEFAULT_SCREEN_TITLE_BAR_HEIGHT_DP)
#            profile =  Profile("Nexus 5", Calculator.XXHDPI, Constants.DEFAULT_OUTPUT_SCREEN_WIDTH_PIXEL, Constants.DEFAULT_OUTPUT_SCREEN_HEIGHT_PIXEL)
            
        self.mWidthPx = 0
        self.mHeightPx = 0
    
        if len(rgbaImage.shape) == 2 :
            self.mHeightPx, self.mWidthPx = rgbaImage.shape
        else:
            self.mHeightPx, self.mWidthPx,channels = rgbaImage.shape
        
        standardScreenWidthDpi = profile.mDpWidth
        standardScreenHeightDpi = profile.mDpHeight
        
#        if Environment.getValue(Environment.KEY_WITH_TITLE_BAR) == False:
#            standardScreenHeightDpi += profile.mDpTitleBarHeight

        scaleType = int(Environment.getValue(Environment.KEY_SCALE_TYPE))

        if scaleType== 3: 
            self.mWidthDpr = profile.mWidth / standardScreenWidthDpi
            # We just need the same dpr here, regardless of dpr of height,
            # because we don't want
            # the height of the output to scale to the screen size
            self.mHeightDpr = self.mWidthDpr

        elif scaleType== 1: 
             ratioWidth = self.mWidthPx / standardScreenWidthDpi
             ratioHeight = self.mHeightPx / standardScreenHeightDpi
            
             self.mWidthDpr = max(ratioWidth, ratioHeight)
             self.mHeightDpr = self.mWidthDpr
        else:
             self.mWidthDpr = self.mWidthPx / standardScreenWidthDpi
             self.mHeightDpr = self.mHeightPx / standardScreenHeightDpi
def t1():
    result = env.get_config_prop("LOGGING_LEVEL")
    print("t1: result = ", result)
    l = getattr(logging, result)
    print("Logging level = ", l)
    print("Logging to DEBUG = ", logging.DEBUG)
def t2():

    logger = env.get_logger()
    print("Logger = ", str(logger))
    logger.debug("Writing debug message")
Beispiel #7
0
    def addChildrenLayout(self, element, rectView, parentLeft, parentTop,
                          rectViewElementInfoMap):
        # Setting background
        if (self.useTransparentBackground(rectView)):
            XmlUtil.addBackgroundColor(element,
                                       ColorUtil.toInt(0, 255, 255, 255),
                                       self.mColorWriter)
#        elif (RectViewTypes.isContanerView(rectView)) :
# We always want to genenate background regard less of the respect
# ratioand Environment.get().getValue(Environment.KEY_KEEP_ASPECT_RATIO) == Boolean.TRUE
# We will not do this if ratio is between input image and output is the same
#            bound = ImageUtil.getImageFromRect(self.mImage, rectView)
#            # We remove children here using 4 layer channel So we have to make sure that when we save it we will not Adding anymore layer
#            newImageBackground = ImageUtil.removeChildren(bound, rectView)
#            drawableId = self.mDrawableWriter.addResourceDirectly(newImageBackground, rectView)
#            XmlUtil.addBackroundImage(element, drawableId)

        else:
            XmlUtil.addBackgroundColor(element, rectView.mColor,
                                       self.mColorWriter)

        for childRectView in rectView.mChildren:
            _id = ""
            # list view has it own index
            if (childRectView.mType == RectViewTypes.VIEW_TYPE_LIST):
                _id = childRectView.mListInfo.xmlId
            else:
                _id = self.getId(LayoutHelper.FRAMELAYOUT_ELEMENT,
                                 childRectView)

            marginLeft = childRectView.x - parentLeft
            marginTop = childRectView.y - parentTop
            childElement = None
            if (self.useTransparentBackground(childRectView)):
                childElement = XmlUtil.addElement(
                    self.mDipCalculator, element,
                    self.getElementTypeForRect(childRectView), childRectView,
                    marginLeft, marginTop, _id)
            else:
                childElement = XmlUtil.addElement(
                    self.mDipCalculator, element,
                    self.getElementTypeForRect(childRectView), childRectView,
                    marginLeft, marginTop, _id, self.mColorWriter)

            rectViewElementInfoMap[childRectView] = ElementInfo(
                childElement, _id)
            self.addChildrenLayout(childElement, childRectView,
                                   childRectView.x, childRectView.y,
                                   rectViewElementInfoMap)

        # image view
        if (rectView.mType == RectViewTypes.VIEW_TYPE_IMAGE):
            drawableId = self.interestedIcons.get(rectView.mImageInfo.iconInfo)
            element.tag = Constants.ELEMENT_IMAGE_VIEW
            XmlUtil.addImageDrawable(element, drawableId)
            # override attributes
            XmlUtil.removeAttribute(element, Constants.ATTRIBUTE_BACKGROUND)
            _id = self.getId(Constants.ELEMENT_IMAGE_VIEW, rectView)
            XmlUtil.addId(element, _id)
            XmlUtil.addScaleType(element, "fitXY")
            rectViewElementInfoMap[rectView] = ElementInfo(element, _id)
        elif (rectView.mType == RectViewTypes.VIEW_TYPE_TEXT):

            textWrapper = rectView.mTextInfo.textWrapper
            stringId = self.mWriter.addResource(textWrapper.text)
            rectView.mTextInfo._id = stringId
            element.tag = Constants.ELEMENT_TEXT_VIEW
            if (Environment.getValue(
                    Environment.KEY_TEXT_WIDTH_WRAP_CONTENT) == True):
                XmlUtil.addSize(self.mDipCalculator, element,
                                Constants.ATTRIBUTE_WRAP_CONTENT,
                                rectView.height)
            else:
                XmlUtil.addSize(self.mDipCalculator, element, rectView.width,
                                rectView.height)

            XmlUtil.addBackgroundColor(element, rectView.mColor,
                                       self.mColorWriter)
            element.set(Constants.ATTRIBUTE_TEXT,
                        XmlUtil.getReferenceResourceId(stringId))
            _id = self.getId(Constants.ELEMENT_TEXT_VIEW, rectView)
            XmlUtil.addId(element, _id)
            textAttributes = textWrapper.getTextAttributes(
                self.mOcr, rectView.height)
            XmlUtil.addTextColor(element, rectView.textColor,
                                 self.mColorWriter)
            stypeId = self.mStyleWriter.addResource(textAttributes)
            element.set(Constants.ATTRIBUTE_STYLE,
                        XmlUtil.getReferenceStyleId(stypeId))
            rectViewElementInfoMap[rectView] = ElementInfo(element, _id)
 def __init__(self, fixReward=False, seed=None):
     super().__init__(
         ENV.DeltaRewardEnv(
             BasicPendulumEnvironment(fixReward=fixReward, seed=seed)))
     return