Skip to content

Instantly share code, notes, and snippets.

View tugstugi's full-sized avatar

Erdene-Ochir Tuguldur tugstugi

View GitHub Profile
@tugstugi
tugstugi / gist:2961712
Created June 20, 2012 19:30
mtd-hack.c
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <linux/err.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
MODULE_LICENSE("GPL");
MODULE_AUTHOR("unknown, 2012");
MODULE_DESCRIPTION("mtd hack copied from CyanogenModXT720");
@tugstugi
tugstugi / gist:2688008
Created May 13, 2012 11:49
v4l: reading NAO camera with mmap
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <fcntl.h>
#include <errno.h>
#include <linux/videodev2.h>
#include <sys/mman.h>
@tugstugi
tugstugi / gist:2652862
Created May 10, 2012 12:57
v4l: reading camera with read() method
/*
* Open the output.rgb with:
* display -size 640x480 -depth 8 -colorspace RGB output.rgb
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <fcntl.h>
@tugstugi
tugstugi / gist:2627647
Created May 7, 2012 13:03
v4l: camera capability and control query
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <linux/videodev2.h>
int main() {
int N = 100;
char* deviceName = "/dev/video0";
int fd = open(deviceName, O_RDWR);
@tugstugi
tugstugi / gist:2558335
Created April 30, 2012 13:22
robocup particle filter
from Tkinter import *
from math import *
import random
GAME_FIELD_PADDING = 0.7
GAME_FIELD_WIDTH = 6.0
GAME_FIELD_HEIGHT = 4.0
PENALTY_AREA_WIDTH = 0.6
PENALTY_AREA_HEIGHT = 2.2
PENALTY_MARK_SIZE = 0.1
@tugstugi
tugstugi / simple_robocup_cv.py
Created February 27, 2012 00:21
robocup ball detector
import cv2.cv as cv
class SimpleBallRecognition:
def __init__(self, image):
self.bgrImage = image
self.ycrcbImage = cv.CreateImage(cv.GetSize(self.bgrImage), cv.IPL_DEPTH_8U, 3)
self.resultImage = cv.CreateImage(cv.GetSize(self.bgrImage), cv.IPL_DEPTH_8U, 3)
self.tmpGrayImage = cv.CreateImage(cv.GetSize(self.bgrImage), cv.IPL_DEPTH_8U, 1)
cv.CvtColor(self.bgrImage, self.ycrcbImage, cv.CV_BGR2YCrCb)