Skip to content

Commit

Permalink
wip #69
Browse files Browse the repository at this point in the history
  • Loading branch information
previ committed Nov 12, 2017
1 parent f3745fd commit 40a72ab
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Binary file modified .camera.py.swp
Binary file not shown.
6 changes: 3 additions & 3 deletions camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,16 @@ def get_average(self):
return avg

def find_line(self):
img = self.get_image().binarize().invert()
img = img.erode().dilate()
img = self.get_image().binarize()
#img = img.erode().dilate()
slices = [0,0,0]
blobs = [0,0,0]
slices[0] = img.crop(0, int(self._camera.out_rgb_resolution[1]/1.2), self._camera.out_rgb_resolution[0], self._camera.out_rgb_resolution[1])
slices[1] = img.crop(0, int(self._camera.out_rgb_resolution[1]/1.5), self._camera.out_rgb_resolution[0], int(self._camera.out_rgb_resolution[1]/1.2))
slices[2] = img.crop(0, int(self._camera.out_rgb_resolution[1]/2.0), self._camera.out_rgb_resolution[0], int(self._camera.out_rgb_resolution[1]/1.5))
coords = [-1, -1, -1]
for idx, slice in enumerate(slices):
blobs[idx] = slice.find_blobs(minsize=4000/(self._cv_image_factor * self._cv_image_factor), maxsize=8000/(self._cv_image_factor * self._cv_image_factor))
blobs[idx] = slice.find_blobs(minsize=300/(self._cv_image_factor * self._cv_image_factor), maxsize=8000/(self._cv_image_factor * self._cv_image_factor))
if len(blobs[idx]):
coords[idx] = (blobs[idx][0].center[0] * 100) / self._camera.out_rgb_resolution[0]
logging.info("line coord: " + str(idx) + " " + str(coords[idx])+ " area: " + str(blobs[idx][0].area()))
Expand Down
6 changes: 3 additions & 3 deletions event.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ def get_instance(cls, node_name=None):

def __init__(self, node_name):
self._node_name = node_name
rospy.init_node(node_name, disable_signals=True)
rospy.init_node(node_name, anonymous=True, disable_signals=True)
self._publishers = {}
self._event_generators = []
self._event_listeners = []

def publish(self, topic, message):
publisher = self._publishers.get(topic)
if publisher is None:
publisher = rospy.Publisher("/" + self._node_name + "/" + topic, std_msgs.msg.String, queue_size=10)
publisher = rospy.Publisher("/" + topic, std_msgs.msg.String, queue_size=10)
self._publishers[topic] = publisher
publisher.publish(json.dumps(message))

def register_event_listener(self, topic, callback):
self._event_listeners.append(rospy.Subscriber("/" + self._node_name + "/" + topic, std_msgs.msg.String, callback))
self._event_listeners.append(rospy.Subscriber("/" + topic, std_msgs.msg.String, callback))

def register_event_generator(self, generator_func):
generator = threading.Thread(target=generator_func)
Expand Down
2 changes: 1 addition & 1 deletion static/js/blockly/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ Blockly.Blocks['coderbot_adv_findARCode'] = {
this.setColour(250);
this.appendDummyInput()
.appendField(Blockly.Msg.CODERBOT_SENSOR_FINDARCODE);
this.setOutput(true, 'String');
this.setOutput(true, 'HashMap');
this.setInputsInline(true);
this.setTooltip(Blockly.Msg.LOGIC_BOOLEAN_TOOLTIP);
}
Expand Down

0 comments on commit 40a72ab

Please sign in to comment.