Skip to content

Instantly share code, notes, and snippets.

View mpkuse's full-sized avatar

Manohar Kuse mpkuse

View GitHub Profile
@mpkuse
mpkuse / binaryproto2numpy.py
Created July 11, 2016 03:29
.binaryproto of caffe to numpy array
# Converts the mean.binaryproto (mean image) to a numpy image.
import caffe
import numpy as np
import sys
blob = caffe.proto.caffe_pb2.BlobProto()
data = open('mean.binaryproto' , 'rb' ).read()
blob.ParseFromString(data)
arr = np.array( caffe.io.blobproto_to_array(blob) )
@mpkuse
mpkuse / CMakeLists.txt
Last active July 25, 2016 06:51
Setting up OpenGL with GLFW, GLEW
cmake_minimum_required (VERSION 2.8)
project (glfw_test)
find_package( glfw3 REQUIRED )
find_package( GLEW REQUIRED )
find_package( OpenGL REQUIRED )
set(CMAKE_CXX_FLAGS "-std=c++11")
add_executable( glDemo gl_test.cpp )
@mpkuse
mpkuse / CMakeLists.txt
Created September 6, 2016 09:10
CMake Project Template
cmake_minimum_required (VERSION 2.8)
project (proto_app)
add_executable( helloDemo hello.cpp )
target_link_libraries( helloDemo )
@mpkuse
mpkuse / XYZ_2_latlong.py
Last active February 5, 2024 10:34
Convert GPS (Latitude and Longitude) to XYZ
""" Give a) points in localcoordinate system b) a gps lat long of the origin of the local coordinate system,
this script helps to convert XYZ to latlong.
Beware that the transformation will be off by an yaw angle. This is because the local cordinate frame is may/or may not align with the East-North-Up frame.
The way it works is XYZ --> ECEF --> geodedic (latlong)
main reference is still the wiki https://en.wikipedia.org/wiki/Geographic_coordinate_conversion#From_ECEF_to_ENU.
However the procedure to convert from ECEF to geodedic in wikip does not give accurate results. Instead the algorithm
@mpkuse
mpkuse / ImuDeadReckon.cpp
Created April 5, 2017 08:12
IMU Dead Reckoning
#include <ImuDeadReckon.h>
/// default constructor. Init the subscribers
ImuDeadReckon::ImuDeadReckon()
{
sub = nh.subscribe( "imu_3dm_gx4/imu", 2, &ImuDeadReckon::imuDataRcvd, this );
pub_dr_pose = nh.advertise<geometry_msgs::PoseStamped>( "/imu/pose", 1 );
// Global Constants
@mpkuse
mpkuse / CMakeLists.txt
Last active October 26, 2020 20:08
OpenCV Keypoint Detection and Matching
cmake_minimum_required(VERSION 2.8.3)
project(vfc)
find_package(OpenCV REQUIRED)
include_directories(
${OpenCV_INCLUDE_DIRS}
)
add_executable( keypoints keypoints.cpp )
@mpkuse
mpkuse / imap_gmail.py
Created September 4, 2017 05:47
Python Read Emails from Gmail with imaplib
import imaplib
import email
mail = imaplib.IMAP4_SSL('imap.gmail.com')
mail.login('USERNAME_HERE', 'PASSWORD_HERE')
print mail.list()
mail.select('inbox')
result, email_list = mail.uid('search', None, "UNSEEN")
#result, email_list = mail.uid('search', None, "ALL")
@mpkuse
mpkuse / README.md
Last active May 6, 2020 12:08
Type3 fonts error when submitting the paper

Often time I come across the type3 font type error when submitting papers to scientific conference. What it means is that you have a non-standard font in your PDF.

For the written text part, just put the following in the preamble of your .tex file and show it fine. \pdfminorversion=4

Another nasty place that these fonts turn up is in your plots. Especially the one using vector graphics. If using matplot (Python) for your plot, just put the following after your import and it fixes the problem.

import matplotlib.pyplot as plt
@mpkuse
mpkuse / README.md
Created April 5, 2018 10:17
Python Multiprocessing

threading and multiprocessing are the modules that provide concurency facility in python. Both provide different utility. Google the difference to know more. But basically threading provides multiple threads (in a single process-context). This can you computing teeth while your data gets loaded. Although multiple threads can be started with this but only 1 thread can be active at a time. Other threads can be sleeping or loading data. Thus, this is not suitable when your threads need to all do number crunching (CPU-bound).

multiprocessing lets you create separate processes. These processes have different memory context. Data needs to be shared with semaphores. Easy way share data is using the Manager class and Manager.list() and Manager.dict() or the multiprocessing.Queues().

@mpkuse
mpkuse / README.md
Last active October 26, 2018 05:16