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
def get_rgb_angular_error_torch(gt_render, pred_render): | |
# The error need to be computed with the normalized rgb image. | |
# Normalized RGB is r = R / (R+G+B), g = G / (R+G+B), b = B / (R+G+B) | |
# The angular distance is the distance between pixel 1 and pixel 2. | |
# It's computed with cos^-1(p1·p2 / ||p1||*||p2||) | |
num = torch.sum((gt_render / torch.sum(gt_render, dim=2, keepdim=True)) * (pred_render / torch.sum(pred_render, dim=2, keepdim=True)), dim=2, keepdim=True) | |
den = (torch.sqrt(torch.sum((gt_render / torch.sum(gt_render, dim=2, keepdim=True))**2, dim=2, keepdim=True)) * torch.sqrt(torch.sum((pred_render / torch.sum(pred_render, dim=2, keepdim=True))**2, dim=2, keepdim=True))) | |
angular_distance = torch.arccos(num / den) |
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 pyredner | |
import torch | |
import imageio | |
import cv2 | |
from difflight.tools.render_envmap import render_envmap | |
root_folder = '/gel/usr/heweb4/datasets/LavalIndoor/params' | |
masks_folder = '/gel/usr/heweb4/datasets/LavalIndoor/maskPanoramas/' | |
input_folder_exr = '/gel/usr/heweb4/datasets/LavalIndoor/1942x971/' |
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
list of numpy arrays to a single numpy array | |
numpy_array = np.array(np.concatenate(tuple(list))) | |
force image resize to specific size | |
convert '*.jpg[200x100!]' resized%03d.png | |
serve html files (with css) accessible through SVN: | |
svn propset svn:mime-type text/css doc/build/html/_static/*.css | |
OpenCV convention: |
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 mss | |
import numpy | |
import cv2 | |
out = cv2.VideoWriter("output.avi", cv2.VideoWriter_fourcc(*'MJPG'), 25.0,(600,400), True) | |
i = 0 | |
while i < 1000: | |
i+=1 | |
with mss.mss() as sct: |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
int main(int argc, char**argv) | |
{ | |
srand (time(NULL)); | |
printf("%d",rand()%atoi(argv[1])); | |
return 0; | |
} |