Skip to content

Instantly share code, notes, and snippets.

View nandor's full-sized avatar

Nandor Licker nandor

  • SiFive
  • Cluj-Napoca, Romania
  • 00:31 (UTC +03:00)
View GitHub Profile
cameraMatrix = cv::Mat::eye(3, 3, CV_32F);
distCoeffs = cv::Mat::zeros(4, 1, CV_32F);
std::vector<cv::Mat> rvecs, tvecs;
float rms = cv::calibrateCamera(
std::vector<std::vector<cv::Point3f>>(kCalibrationPoints, grid),
imagePoints,
rgb.size(),
cameraMatrix,
@nandor
nandor / Chess.hs
Last active October 20, 2015 18:59
repeatM :: Monad m => m a -> (a -> m a) -> Int -> m a
repeatM m _ 0
= m
repeatM m f n
= repeatM (m >>= f) f (n - 1)
inRange :: (Int, Int) -> Bool
inRange (x, y)
= x `elem` [0..9] && y `elem` [0..9]
@nandor
nandor / ransac.html
Created October 6, 2015 09:11
RANSAC implementation in JS
<!DOCTYPE html>
<html>
<head>
<title>RANSAC</title>
<style type="text/css">
#canvas, body, html {
width: 100%;
height: 100%;
margin: 0; padding: 0;
}
@nandor
nandor / kernel.cc
Created October 5, 2015 18:09
OpenCL stuff
// (C) 2015 Nandor Licker. All rights reserved.
#include "kernel.h"
namespace lenet {
namespace cl {
void CheckCLError(const std::string &file, size_t line, const std::string &func, cl_int err)
{
@nandor
nandor / hough.cpp
Created September 29, 2015 01:49
Hough Transform Implementation
// (C) 2015 Nandor Licker. All rights reserved.
#include <cstdlib>
#include <exception>
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
@nandor
nandor / id3.cpp
Last active December 13, 2022 14:21
ID3 algorithm implementation in C++.
#include <cmath>
#include <cstdlib>
#include <array>
#include <fstream>
#include <iostream>
#include <memory>
#include <sstream>
#include <unordered_map>
#include <vector>
@nandor
nandor / js
Created May 30, 2015 14:18
JS stuff
return goog.object.getValues(goog.object.filter(all, function(elem) {
return goog.array.some(elem.getVertices(), function(v) {
return goog.array.every(planes, function(plane) {
return goog.vec.Vec3.dot(v.position, plane.n) + plane.d >= 0;
});
});
}, this));
@nandor
nandor / LVA.hs
Created October 24, 2014 16:38
Live Variable Analysis in haskell
liveVariables :: SFunction -> Map Int (Set SVar)
liveVariables func@SFunction{..}
= fst . last . takeWhile snd . iterate next $ (initial, True)
where
(cfg, _) = buildFlowGraph func
labels = map fst . Map.toList $ sfBlocks
initial = foldr (\x -> Map.insert x Set.empty) Map.empty labels
next (mp, _)
= foldl update (mp, False) labels
@nandor
nandor / thumb.cc
Created June 26, 2014 18:20
Interpreter loop
// This file is part of the PiEMU Project
// Licensing information can be found in the LICENSE file
// (C) 2014 Nandor Licker. All rights reserved.
#include "common.h"
// -----------------------------------------------------------------------------
static void Branch(THUMBState *, uint16_t) FORCEINLINE;
static void Add(THUMBState *, int32_t &, int32_t, int32_t) FORCEINLINE;
static void Sub(THUMBState *, int32_t &, int32_t, int32_t) FORCEINLINE;
@nandor
nandor / msquares.coffee
Created June 22, 2014 07:58
Marching Squares
# This file is part of the Proto Project
# Licensing information can be found in the LICENSE file
# (C) 2014 Nandor Licker. All rights reserved.
# Computes a normal vector
normal = (a, b, c) ->
d1 = vec3.create()
vec3.sub(d1, b, a)
d2 = vec3.create()
vec3.sub(d2, c, a)