Skip to content
This repository has been archived by the owner on Jun 19, 2020. It is now read-only.

Commit

Permalink
add update for color_profile
Browse files Browse the repository at this point in the history
  • Loading branch information
Weijian Zeng committed Jan 28, 2020
1 parent 1ea35d5 commit 8c73568
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion processing/cvfilters.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def hsv_threshold(input,profile):
sat = profile.hsv_sat
val = profile.hsv_val

out = cv2.cvtColor(input, cv2.COLOR_BGR2HSV)
out = cv2.cvtColor(input, cv2.COLOR_RGB2HSV)
return cv2.inRange(out, (hue.min, sat.min, val.min), (hue.max, sat.max, val.max))


Expand Down
46 changes: 46 additions & 0 deletions profiles/color_profile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import json
import logging
from os.path import abspath, dirname, join, exists

root_path = abspath(join(dirname(__file__)))

logger = logging.getLogger(__name__)

class ColorProfileEncoder(json.JSONEncoder):
def default(self, obj):
Expand Down Expand Up @@ -32,6 +38,46 @@ def __init__(self, camera_mode):
self.hsv_val = Range(0,255)


camera_mode_filepath = join(root_path, 'color_profile_%s.json' % camera_mode)

if exists(camera_mode_filepath):
logger.info("loading from %s" % camera_mode_filepath)
with open(camera_mode_filepath, mode="rb" ) as f:
profile = json.loads(f.read())
self.update(profile)

def update(self, profile):

color_profile = self

color_profile.red.min = int(profile['rgb']['r']['min'])
color_profile.red.max = int(profile['rgb']['r']['max'])

color_profile.green.min = int(profile['rgb']['g']['min'])
color_profile.green.max = int(profile['rgb']['g']['max'])

color_profile.blue.min = int(profile['rgb']['b']['min'])
color_profile.blue.max = int(profile['rgb']['b']['max'])

color_profile.hsv_hue.min = int(profile['hsv']['h']['min'])
color_profile.hsv_hue.max = int(profile['hsv']['h']['max'])

color_profile.hsv_sat.min = int(profile['hsv']['s']['min'])
color_profile.hsv_sat.max = int(profile['hsv']['s']['max'])

color_profile.hsv_val.min = int(profile['hsv']['v']['min'])
color_profile.hsv_val.max = int(profile['hsv']['v']['max'])

color_profile.hsl_hue.min = int(profile['hsl']['h']['min'])
color_profile.hsl_hue.max = int(profile['hsl']['h']['max'])

color_profile.hsl_sat.min = int(profile['hsl']['s']['min'])
color_profile.hsl_sat.max = int(profile['hsl']['s']['max'])

color_profile.hsl_lum.min = int(profile['hsl']['l']['min'])
color_profile.hsl_lum.max = int(profile['hsl']['l']['max'])


def to_encodable(self):
rgb = dict(
r=dict(min=self.red.min,
Expand Down

0 comments on commit 8c73568

Please sign in to comment.