docstr: Test DetectOS and DetectOrientationScript (tesseract v4+).
docstr_tok: ["Test","DetectOS","and","DetectOrientationScript","(","tesseract","v4+",")","."]
code: def test_detect_os(self):
      """Test DetectOS and DetectOrientationScript (tesseract v4+)."""
      self._api.SetPageSegMode(tesserocr.PSM.OSD_ONLY)
      self._api.SetImageFile(self._image_file)
      orientation = self._api.DetectOS()
      all(
          self.assertIn(k, orientation)
          for k in [
              "sconfidence",
              "oconfidence",
              "script",
              "orientation",
          ]
      )
      self.assertEqual(orientation["orientation"], 0)
      # this is sorted alphabetically!
      languages = tesserocr.get_languages()[1]
      self.assertLess(orientation["script"], len(languages))
      # therefore does not work
      # script_name = languages[orientation["script"]]
      # self.assertEqual(script_name, 'Latin') # cannot test: not reliable
      if _TESSERACT_VERSION >= 0x3999800:
          orientation = self._api.DetectOrientationScript()
          all(
              self.assertIn(k, orientation)
              for k in [
                  "orient_deg",
                  "orient_conf",
                  "script_name",
                  "script_conf",
              ]
          )
          self.assertEqual(orientation["orient_deg"], 0)
          self.assertEqual(orientation["script_name"], "Latin")
  
imports: import unittest
  import re
  import os.path
  import tesserocr
label_desc: Use image node_id 17 for calling the TestTessBaseApi obj's underlying member method code with example usage: obj.test_detect_os() without return types