python colorsys_Python colorsys.hsv_to_rgb方法代碼示例

本文整理匯總了Python中colorsys.hsv_to_rgb方法的典型用法代碼示例。如果您正苦於以下問題:Python colorsys.hsv_to_rgb方法的具體用法?Python colorsys.hsv_to_rgb怎麽用?Python colorsys.hsv_to_rgb使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在模塊colorsys的用法示例。

在下文中一共展示了colorsys.hsv_to_rgb方法的25個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Python代碼示例。

示例1: create_unique_color_float

​點讚 6

# 需要導入模塊: import colorsys [as 別名]

# 或者: from colorsys import hsv_to_rgb [as 別名]

def create_unique_color_float(tag, hue_step=0.41):

"""Create a unique RGB color code for a given track id (tag).

The color code is generated in HSV color space by moving along the

hue angle and gradually changing the saturation.

Parameters

----------

tag : int

The unique target identifying tag.

hue_step : float

Difference between two neighboring color codes in HSV space (more

specifically, the distance in hue channel).

Returns

-------

(float, float, float)

RGB color code in range [0, 1]

"""

h, v = (tag * hue_step) % 1, 1. - (int(tag * hue_step) % 4) / 5.

r, g, b = colorsys.hsv_to_rgb(h, 1., v)

return r, g, b

開發者ID:nwojke,項目名稱:deep_sort,代碼行數:25,

示例2: generate

​點讚 6

# 需要導入模塊: import colorsys [as 別名]

# 或者: from colorsys import hsv_to_rgb [as 別名]

def generate(self):

model_path = os.path.expanduser(self.model_path)

assert model_path.endswith('.h5'), 'Keras model must be a .h5 file.'

self.yolo_model = load_model(model_path, compile=False)

print('{} model, anchors, and classes loaded.'.format(model_path))

# Generate colors for drawing bounding boxes.

hsv_tuples = [(x / len(self.class_names), 1., 1.)

for x in range(len(self.class_names))]

self.colors = list(map(lambda x: colorsys.hsv_to_rgb(*x), hsv_tuples))

self.colors = list(

map(lambda x: (int(x[0] * 255), int(x[1] * 255), int(x[2] * 255)),

self.colors))

random.seed(10101) # Fixed seed for consistent colors across runs.

random.shuffle(self.colors) # Shuffle colors to decorrelate adjacent classes.

random.seed(None) # Reset seed to default.

# Generate output tensor targets for filtered bounding boxes.

self.input_image_shape = K.placeholder(shape=(2, ))

boxes, scores, classes = yolo_eval(self.yolo_model.output, self.anchors,

len(self.class_names), self.input_image_shape,

score_threshold=self.score, iou_threshold=self.iou)

return boxes, scores, classes

開發者ID:jguoaj,項目名稱:multi-object-tracking,代碼行數:26,

示例3: set_brightness

​點讚 6

# 需要導入模塊: import colorsys [as 別名]

# 或者: from colorsys import hsv_to_rgb [as 別名]

def set_brightness(channel, br):

global status

if channel == 'all':

for ch in status['colour']:

c = status['colour'][ch]

r, g, b = c

h, s, v = rgb_to_hsv(r, g, b)

v = int(br) / 100.0

r, g, b = [int(c * 255) for c in hsv_to_rgb(h, s, v)]

status['colour'][ch] = [r, g, b]

if not all(status['state'].values()) == 0:

mote_on(status)

else:

c = status['colour'][int(channel)]

r, g, b = c

h, s, v = rgb_to_hsv(r, g, b)

v = int(br) / 100.0

r, g, b = [int(c * 255) for c in hsv_to_rgb(h, s, v)]

status['colour'][int(channel)] = [r, g, b]

if not status['state'][int(channel)] == 0:

mote_on(status)

return jsonify(status)

## Returns the current API version to the requester

開發者ID:pimoroni,項目名稱:mote,代碼行數:26,

示例4: test_hsv_values

​點讚 6

# 需要導入模塊: import colorsys [as 別名]

# 或者: from colorsys import hsv_to_rgb [as 別名]

def test_hsv_values(self):

values = [

# rgb, hsv

((0.0, 0.0, 0.0), ( 0 , 0.0, 0.0)), # black

((0.0, 0.0, 1.0), (4./6., 1.0, 1.0)), # blue

((0.0, 1.0, 0.0),

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值