当前位置: 首页>>代码示例>>Python>>正文


Python Histogram.load方法代码示例

本文整理汇总了Python中histogram.Histogram.load方法的典型用法代码示例。如果您正苦于以下问题:Python Histogram.load方法的具体用法?Python Histogram.load怎么用?Python Histogram.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在histogram.Histogram的用法示例。


在下文中一共展示了Histogram.load方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_hue_histograms

# 需要导入模块: from histogram import Histogram [as 别名]
# 或者: from histogram.Histogram import load [as 别名]
 def load_hue_histograms(self):
     for h in self.known_histograms.keys():
         hist = Histogram()
         hist.load(self.known_histograms[h][0])
         self.known_histograms[h][1] = hist
     for h in self.known_histograms:
         print h
         print self.known_histograms[h][1]
开发者ID:EduFill,项目名称:components,代码行数:10,代码来源:cube_color_detector.py

示例2: test_hdf5

# 需要导入模块: from histogram import Histogram [as 别名]
# 或者: from histogram.Histogram import load [as 别名]
 def test_hdf5(self):
     try:
         import h5py
         h = self.h.clone()
         filename = 'h.hdf5'
         h.save(filename)
         hh = Histogram.load(filename)
         assert h.isidentical(hh)
     except ImportError:
         pass
开发者ID:theodoregoetz,项目名称:histogram,代码行数:12,代码来源:test_serialization.py

示例3: __init__

# 需要导入模块: from histogram import Histogram [as 别名]
# 或者: from histogram.Histogram import load [as 别名]
class SkinDetector:
    def __init__(self, topic=DEF_TOPIC_NAME, hist_file=DEF_HISTOGRAM_FILE):
        rospy.init_node("skin_detection", anonymous=True)
        rospy.Subscriber(topic, Image, self.rgb_cb)
        cv2.namedWindow("wnd_orig")
        cv2.namedWindow("wnd_prob")
        cv2.namedWindow("wnd_skin")
        self.skin_threshold = 127
        cv2.createTrackbar("track_skin", "wnd_skin", self.skin_threshold, 255, self.on_skin_track)
        rospy.on_shutdown(self.on_shutdown)
        self.hist = Histogram()
        self.hist.load(hist_file)

    def on_skin_track(self, pos, *argv):
        self.skin_threshold = pos

    def find_skin(self, img):
        img_hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
        mask = hsv_filter_mask(img_hsv)
        back_proj = calc_back_proj(img_hsv, self.hist.hist, hsv=True)
        back_proj &= mask
        skin_bin = cv2.threshold(back_proj, self.skin_threshold, 255, cv2.THRESH_BINARY)
        return (back_proj, skin_bin[1])

    def rgb_cb(self, msg):
        try:
            img = bridge.imgmsg_to_cv(msg, "bgr8")
            img = np.asarray(img)
        except CvBridgeError, e:
            print >> stderr, "Cannot convert from ROS msg to CV image:", e

        (img_prob, img_skin) = self.find_skin(img)
        cv2.imshow("wnd_orig", img)
        cv2.imshow("wnd_prob", img_prob)
        cv2.imshow("wnd_skin", img_skin)
        ch = cv2.waitKey(3)
        if ch == 27:
            rospy.signal_shutdown("Quit")
        elif ch == ord(" "):
            cv2.imwrite("img_prob.png", img_prob)
开发者ID:,项目名称:,代码行数:42,代码来源:

示例4: test_root

# 需要导入模块: from histogram import Histogram [as 别名]
# 或者: from histogram.Histogram import load [as 别名]
 def test_root(self):
     # For CERN/ROOT, we resorted to converting everything
     # into float64's so histograms are not typically
     # "identical" but they should be "close"
     try:
         import ROOT
         h = self.h.clone()
         filename = 'h.root'
         self.h.save(filename)
         hh = Histogram.load(filename)
         assert np.allclose(h.data,hh.data)
         assert np.allclose(h.uncert,hh.uncert)
         assert h.label == hh.label
         assert h.title == hh.title
         for a,aa in zip(h.axes,hh.axes):
             assert np.allclose(a.edges,aa.edges)
             assert a.label == aa.label
     except ImportError:
         pass
开发者ID:theodoregoetz,项目名称:histogram,代码行数:21,代码来源:test_serialization.py

示例5: _to_unicode

# 需要导入模块: from histogram import Histogram [as 别名]
# 或者: from histogram.Histogram import load [as 别名]
    def _to_unicode(s):
        if not isinstance(s,unicode):
            return unicode(s,'utf-8')
        else:
            return s
    h.title = _to_unicode(h.title)
    h.label = _to_unicode(h.label)
    for ax in h.axes:
        ax.label = _to_unicode(ax.label)


infiles = ['h2','h3','h2.hdf5','h3.hdf5']

for infile in infiles:
    print(infile)
    hh = Histogram.load(infile)
    assert h.isidentical(hh)


# For CERN/ROOT, we resorted to converting everything
# into float64's so histograms are not typically
# "identical" but they should be "close"
infiles = ['h2.root','h3.root']

for infile in infiles:
    print(infile)
    hh = Histogram.load(infile)
    assert np.allclose(h.data,hh.data)
    assert np.allclose(h.uncert,hh.uncert)
    assert h.label == hh.label
    assert h.title == hh.title
开发者ID:theodoregoetz,项目名称:histogram,代码行数:33,代码来源:read.py

示例6: test_npz

# 需要导入模块: from histogram import Histogram [as 别名]
# 或者: from histogram.Histogram import load [as 别名]
 def test_npz(self):
     h = self.h.clone()
     filename = 'h'
     h.save(filename)
     hh = Histogram.load(filename)
     assert h.isidentical(hh)
开发者ID:theodoregoetz,项目名称:histogram,代码行数:8,代码来源:test_serialization.py


注:本文中的histogram.Histogram.load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。