Skip to content

Instantly share code, notes, and snippets.

@ivder
ivder / TensorflowMain.cc
Last active February 19, 2019 03:33
Tensorflow C++ Inference API Modification (Multiple Input Images). This C++ inference code acts mostly the same way as main.cc from https://www.tensorflow.org/tutorials/images/image_recognition. The code is modified so it can take multiple image in directory and classify those images. The inference result also saved in Inference_Result.txt
/* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@ivder
ivder / NMEAconverter.py
Created February 19, 2019 03:39
Convert the GPS data that extracted from GoPro Camera to NMEA-GPRMC format
# -*- coding: utf-8 -*-
import time
import datetime
import csv
import os
def lat_lon(n):
a,b=divmod(n,1)
total=(a*100)+(b*60)
return format(total, '.5f')
@ivder
ivder / KmlConverter.py
Created February 19, 2019 03:42
Convert GPS information from text to KML format that can be viewed with Google Earth (1 KML file for all coordinate point)
import simplekml
import os
def kml_converter(inputfile,kml):
f = open(inputfile,"r")
for row in f:
data=row.split(",")
splitdata=data[0].split("\\")
kml.newpoint(name=splitdata[6], coords=[(data[2],data[1])])
@ivder
ivder / singleKmlConverter.py
Created February 19, 2019 03:43
Convert GPS information from text to KML format that can be viewed with Google Earth (1 KML file for each coordinate point)
# -*- coding: utf-8 -*-
import simplekml
import os
def kml_converter(inputfile,dirlist,filelist):
f = open(inputfile,"r")
kml=simplekml.Kml()
for row in f:
data=row.split(",")
splitdata=data[0].split("\\")
@ivder
ivder / googleKmlExtractor.py
Created February 19, 2019 03:45
Convert longitude and latitude coordinate that extracted from Google Earth KML format to txt format
# -*- coding: utf-8 -*-
text = "127.1245143092074,37.48605020263803,0 127.1227918767437,37.48604832058984,0 127.1243979114171,37.48275282702311,0 127.1272652345932,37.47650564339881,0 127.1269005294987,37.47562108198129,0 127.1264902143204,37.47470615899766,0 127.1261222584311,37.47437246324513,0 127.126157672444,37.47371699021247,0 127.1257493554023,37.47291716136547,0 127.1254389085777,37.47213888086183,0 127.125117506637,37.47062544236839,0 127.1251423798022,37.46920765516041,0 127.1252461714744,37.46822418442232,0 127.1256680519576,37.46484452642618,0 127.1254663648703,37.46252995708048,0 127.1253955340772,37.45829374652769,0 127.1258727729014,37.45441627283644,0 127.1260535025414,37.44991980413442,0 127.1249501399596,37.44592241319028,0 127.1241308101934,37.44408589006341,0 127.123498216068,37.44253029858053,0 127.1229866609585,37.44132886161613,0 127.122682481901,37.43719912651704,0 127.1230781217638,37.43530852646552,0 127.1230777605002,37.43392112083875,0 127.1234248877856,37.43258926522761,0 127.123
@ivder
ivder / CSVReader.cpp
Created February 19, 2019 03:47
Read information from CSV format file and skip first several (7) lines
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <iterator>
//#include "opencv2/imcodecs.hpp"
#include <sstream>
@ivder
ivder / GpsCoordVideoFrame.cpp
Created February 19, 2019 03:53
Extract GPS information from CSV file (rendered from GoPro). Match the video frame and gps coords, so in 1 second of video has 1 assigned coordinate. Play the video
int main(int argc, char** argv) {
int frameidx, frametotal,fs;
int count = 0;
int idx = 0;
int idxrecord = 0;
int framecount = 1;
int gpsskip = 5;
int divrange = 0;
double firstsec, tempsec = 0;
cout << fixed;
@ivder
ivder / BlackFrameChecker.cpp
Created February 19, 2019 03:54
Check black frame by splitting video color channel
int main(int argc, char *argv[]) {
int frameidx;
int blackframecnt = 0;
VideoCapture capture("black.mp4");
Mat frame;
while (true) {
if (!capture.read(frame)) {
break;
}
Mat output(frame.size(), frame.type());
@ivder
ivder / SharpnessTest.cpp
Created February 19, 2019 03:55
Test the video sharpness
int main(int argc, char** argv)
{
VideoCapture capture("GOPR0632.MP4");
Mat frame, result;
while (true) {
if (!capture.read(frame)) {
break;
}
cv::GaussianBlur(frame, result, cv::Size(0, 0), 3);
addWeighted(frame, 1.5, result, -0.5, 0, result);
@ivder
ivder / HVSTest.cpp
Last active February 19, 2019 03:58
Experiment with Hue, Saturation and Value of image
//Global variables
Mat src, img, image;
//int elem1 = 255;
int elem2 = 234;
int elem3 = 187;
/** @function main */
int main(int argc, char** argv)
{