NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.
If you are not into long explanations, see [Paolo Bergantino’s answer][2].
| /* | |
| * V4L2 video capture example | |
| * | |
| * This program can be used and distributed without restrictions. | |
| * | |
| * This program is provided with the V4L2 API | |
| * see http://linuxtv.org/docs.php for more information | |
| */ | |
| #include <stdio.h> |
NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.
If you are not into long explanations, see [Paolo Bergantino’s answer][2].
| /* | |
| * use -lpthread when build. | |
| */ | |
| #include <semaphore.h> | |
| #include <stdio.h> | |
| #include <string.h> | |
| #include <stdlib.h> | |
| #include <sys/mman.h> | |
| #include <sys/types.h> |
| // fileResponseWriter wraps an http.ResponseWriter and a File | |
| // passing it to an http.Handler's ServeHTTP | |
| // will write to both the file and the response. | |
| type fileResponseWriter struct { | |
| file io.Writer | |
| resp http.ResponseWriter | |
| multi io.Writer | |
| } |
| from keras.preprocessing.image import ImageDataGenerator | |
| from keras.datasets import cifar10 | |
| import numpy as np | |
| NUM_TO_AUGMENT=5 | |
| #load dataset | |
| (X_train, y_train), (X_test, y_test) = cifar10.load_data() | |
| # augumenting | |
| print("Augmenting training set images...") | |
| datagen = ImageDataGenerator(rotation_range=40, width_shift_range=0.2, height_shift_range=0.2, zoom_range=0.2, horizontal_flip=True, fill_mode='nearest') |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include "platform.h" | |
| #include "threadapi.h" | |
| #include "crt_abstractions.h" | |
| #include "iothub_client.h" | |
| #include "iothub_message.h" | |
| #include "iothubtransportamqp.h" |
| import luma.core.serial | |
| from luma.oled.device import sh1106 | |
| def main(): | |
| serial = i2c(port=1, address=0x3C) | |
| device = sh1106(serial) | |
| img_path = 'raspivn.bmp' | |
| logo = Image.open(img_path).convert("RGBA") | |
| fff = Image.new(logo.mode, logo.size, (255,) * 4) |
| import smbus | |
| import time | |
| I2C_ADDR = 0x27 # dung lenh sudo i2cdetect -y 1 ban se thay dia chi cua module lcd la 0x27 | |
| LCD_WIDTH = 16 # so ki tu tren 1 dong | |
| LCD_CHR = 1 # Gui ki tu | |
| LCD_CMD = 0 # Gui lenh |
| sudo apt-get install git-core | |
| sudo apt-get update | |
| sudo apt-get upgrade | |
| git clone git://git.drogon.net/wiringPi | |
| cd wiringPi | |
| ./build | |
| cd examples | |