Skip to content

Instantly share code, notes, and snippets.

View lp6m's full-sized avatar
🏠
Working from home

Yasuhiro Nitta lp6m

🏠
Working from home
  • Kyoto -> Tokyo -> Osaka
  • 19:37 (UTC +09:00)
  • X @lp6m1
View GitHub Profile
@lp6m
lp6m / generate_sample.R
Created November 7, 2019 08:06
Generate bayesian network sample data from learned network structure on R
#sudo apt install r-base-core #the latest version will not be installed by this command
#install.packages("bnlearn", dependencies = TRUE)
library(bnlearn)
data(alarm)
res = read.bif("./alarm.bif") #http://www.bnlearn.com/bnrepository/discrete-medium.html#alarm
sim = rbn(res, 500, alarm)
write.csv(sim, "./alarm.csv")
@lp6m
lp6m / bdeu_score.cpp
Created October 6, 2019 08:40
bdeu_score.cpp
/*example dataset
4 3
A B C D
A B
B C
D C
10
1 1 0 1
0 2 1 1
2 1 0 0
#This shell script refers this tip : https://qiita.com/ikwzm/items/be06b07e26cbf05fec2b
#rootfs which this script generates is compatible for v2019.1 of https://github.com/ikwzm/ZynqMP-FPGA-Linux
#### Setup APT
distro=bionic
export LANG=C
/debootstrap/debootstrap --second-stage
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <sys/types.h>
#include <sys/mman.h>
#define DMA_INTAKE_DMACR (0x0000)
@lp6m
lp6m / hog.cpp
Created December 16, 2018 08:47
void hog(cv::Mat img, double *dst){
const int s_row = 32;//img.rows;
const int s_col = 64;//img.cols;
const int c_row = 12;
const int c_col = 12;
const int b_row = 2;
const int b_col = 2;
int n_cells_row = s_row / c_row; // number of cells along row-axis //2
int n_cells_col = s_col / c_col; // number of cells along col-axis //5
const int orientations = 8;
void hog(cv::Mat img, double *dst){
const int s_row = 32;//img.rows;
const int s_col = 64;//img.cols;
const int c_row = 12;
const int c_col = 12;
const int b_row = 2;
const int b_col = 2;
int n_cells_row = s_row / c_row; // number of cells along row-axis //2
int n_cells_col = s_col / c_col; // number of cells along col-axis //5
const int orientations = 8;
@lp6m
lp6m / pcam.cpp
Created December 6, 2018 08:56
永久財産
/*
before run this code, you should run the following commands.
media-ctl -d /dev/media0 -V '"ov5640 2-003c":0 [fmt:UYVY/'1920x1080'@1/'15' field:none]'
media-ctl -d /dev/media0 -V '"43c60000.mipi_csi2_rx_subsystem":0 [fmt:UYVY/'1920x1080' field:none]'
*/
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
@lp6m
lp6m / get_pcam_image2.cpp
Created October 22, 2018 13:09
Get Pcam 5C image through HLS core via V4L2 API
/*
Target board: ZYBO Z7-20
Kernel&Circuit:https://github.com/Digilent/Petalinux-Zybo-Z7-20
Distribution: Ubuntu 16.04
https://rcn-ee.com/rootfs/eewiki/minfs/ubuntu-16.04.3-minimal-armhf-2017-10-07.tar.xz
Thanks to @hokim.
Xilinx Form: https://forums.xilinx.com/t5/Embedded-Linux/can-t-get-image-from-PCam-5C-on-Ubuntu-running-on-ZYBO-Z7-20/m-p/882879#M28057
Before run this code, you must run the following commands.
@lp6m
lp6m / system_user.dtsi
Created October 22, 2018 11:17
Modified Device Tree
/include/ "system-conf.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/media/xilinx-vip.h>
/ {
model = "Zynq Zybo Z7 Development Board";
compatible = "digilent,zynq-zyboz7", "xlnx,zynq-7000";
chosen {
bootargs = "console=ttyPS0,115200 earlyprintk uio_pdrv_genirq.of_id=generic-uio";
@lp6m
lp6m / system_user.dtsi
Created October 22, 2018 09:10
Cutom Device Tree
/include/ "system-conf.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/media/xilinx-vip.h>
/ {
model = "Zynq Zybo Z7 Development Board";
compatible = "digilent,zynq-zyboz7", "xlnx,zynq-7000";
chosen {
bootargs = "console=ttyPS0,115200 earlyprintk uio_pdrv_genirq.of_id=generic-uio";