This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import inspect | |
import sys | |
import os | |
import time | |
connection_string = "udp:127.0.0.1:14551" | |
# connection_string = "/dev/ttyACM0" | |
# Import DroneKit-Python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import time | |
from dronekit import connect, VehicleMode | |
vehicle = connect('udp:127.0.0.1:14551', wait_ready = True, source_system = 255) | |
def send_vision_position_message(): | |
x, y, z = np.random.rand(3, ) * 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# metrics | |
def dice_coef(y_true, y_pred): | |
y_true_f = K.flatten(y_true) | |
y_pred = K.cast(y_pred, 'float32') | |
y_pred_f = K.cast(K.greater(K.flatten(y_pred), 0.5), 'float32') | |
intersection = y_true_f * y_pred_f | |
score = 2. * K.sum(intersection) / (K.sum(y_true_f) + K.sum(y_pred_f)) | |
return score | |
#losses |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import numpy as np | |
import cv2 | |
def mask_to_label(mask_rgb): | |
pascal_palette = np.array([(0, 0, 0), (192, 128, 128)], dtype=np.uint8) | |
mask_labels = np.ones(mask_rgb.shape[:2]) | |
pixel = 0 | |
for i in range(mask_rgb.shape[0]): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import cv2 | |
data = cv2.imread(path) | |
r1, g1, b1 = 255, 0,0 # Original value | |
r2, g2, b2 = 255, 255, 255 # Value that we want to replace it with | |
blue, green, red = data[:,:,0], data[:,:,1], data[:,:,2] | |
mask = (red == r1) & (green == g1) & (blue == b1) |