This file contains hidden or 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
""" | |
One-hot-encodes segmentation map | |
@params | |
y: np.ndarray | |
HxWx1 seegmentation map where each element is in set {0,...,num_labels} | |
num_labels: int | |
Defines the set {0,...,num_labels} which is used to one-hot-encode the segmentation map | |
Ex. For annotation segmentation, we have 26 letters, so we say 26. It is assumed that a 0 means no class of interest. | |
@return | |
target: np.ndarray |
This file contains hidden or 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
BG_COLOR = 209 | |
BG_SIGMA = 5 | |
MONOCHROME = 1 | |
def blank_image(width=1024, height=1024, background=BG_COLOR): | |
""" | |
It creates a blank image of the given background color | |
""" | |
img = np.full((height, width, MONOCHROME), background, np.uint8) | |
return img |
This file contains hidden or 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
IEnumerator CreateMesh(){ | |
while(inFirst) | |
yield return new WaitForSeconds(0.1f); | |
int meshID = 97; | |
int cur = 0; | |
var resources = Resources.FindObjectsOfTypeAll(typeof(Material)); | |
foreach(var face in mList){ | |
int num_of_vertices = Convert.ToInt32(face[face.Count-1]); | |
// should we make it hollow? | |
if (mMap["special"] == 'H' && cur < 4){ |
This file contains hidden or 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
public class Triangulator | |
{ | |
private List<Vector2> m_points = new List<Vector2>(); | |
public Triangulator (Vector2[] points) { | |
m_points = new List<Vector2>(points); | |
} | |
public int[] Triangulate() { | |
List<int> indices = new List<int>(); |
This file contains hidden or 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
public void OnTrackableStateChanged( | |
TrackableBehaviour.Status previousStatus, | |
TrackableBehaviour.Status newStatus) | |
{ | |
if (newStatus == TrackableBehaviour.Status.DETECTED || | |
newStatus == TrackableBehaviour.Status.TRACKED || | |
newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED) | |
{ | |
Debug.Log("Detected"); |
This file contains hidden or 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
UnityWebRequest www = UnityWebRequest.Get("http://SERVERIP:PORT/data"); | |
yield return www.SendWebRequest(); | |
Debug.Log(www.responseCode); | |
if(www.isNetworkError || www.isHttpError || www.responseCode == 500) { | |
GameObject myObject = GameObject.Find("ARCamera"); | |
myObject.GetComponent<Buttons>().showError("Need to Capture Front and Side!"); | |
yield return new WaitForSeconds(3); | |
myObject.GetComponent<Buttons>().clearError(); | |
} |
This file contains hidden or 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
IEnumerator TakePhoto(string type) // Start this Coroutine on some button click | |
{ | |
// NOTE - you almost certainly have to do this here: | |
yield return new WaitForEndOfFrame(); | |
Texture2D tex = new Texture2D(Screen.width, Screen.height,TextureFormat.RGB24, false); | |
tex.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0); | |
tex.Apply(); |
This file contains hidden or 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
def deal_post_data(self): | |
ctype, pdict = cgi.parse_header(self.headers['Content-Type']) | |
pdict['boundary'] = bytes(pdict['boundary'], "utf-8") | |
pdict['CONTENT-LENGTH'] = int(self.headers['Content-Length']) | |
if ctype == 'multipart/form-data': | |
form = cgi.FieldStorage( fp=self.rfile, headers=self.headers, environ={'REQUEST_METHOD':'POST', 'CONTENT_TYPE':self.headers['Content-Type'], }) | |
# typeOfImage = form["Type"].value + '.png' | |
bbox = { | |
'x':int(form["x"].value), | |
'y':int(form["y"].value), |
This file contains hidden or 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
def get_mesh(self): | |
if processor.ready_to_send(): | |
faces = processor.get_faces() | |
"""Respond to a GET request.""" | |
self.send_response(200) | |
self.send_header("Content-type", "text") | |
self.end_headers() | |
for i in range(len(faces)): | |
self.wfile.write("N".encode()) | |
self.wfile.write(str(len(faces[i])).encode()) |
This file contains hidden or 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
def create3DFaces(sideHull,frontHull): | |
sideHull = normalize(sideHull) | |
frontHull = normalize(frontHull) | |
sideHull = addZAxis(sideHull) | |
frontHull = addZAxis(frontHull) | |
frontHull = rotate_by_90(frontHull) | |
frontHull,sideHull,hull_back = match_front_face(frontHull,sideHull) | |
faces = construct_faces(frontHull,hull_back) | |
faces = scale_down_faces(faces) | |
return faces |