Skip to content

Instantly share code, notes, and snippets.

View mpkuse's full-sized avatar

Manohar Kuse mpkuse

View GitHub Profile
@mpkuse
mpkuse / README.md
Last active August 22, 2018 10:10
OpenCV 3 Ellipse Example Python

Lot of people have been having issues plotting an ellipse in opencv. Some of the errors one gets are:

TypeError: function takes exactly 3 arguments (2 given)

TypeError: ellipse() takes at most 5 arguments (6 given)

Here is my working code for plotting ellipse in opencv 3 python. I have tested on my Ubuntu 16.04 PC with OpenCV version '3.1.0-dev'.

@mpkuse
mpkuse / README.md
Last active August 10, 2018 04:45
USB Devices Communication and Writing Custom Drivers

Tools and Utilities for USB-TTL Communication

On Linux, USB devices comeup as files under /dev/ttyUSB0 and so on. One can create custom USB devices (with little bit of hardware tinkering). These devices can be based on USB-TTL converters. These are available with USB-A, mini-USB, micro-USB. These devices are almost invariably uses FTDI chips. Can use the program FT_Prog to flash the ftdi chip to set your own custom device names. It is also possible to use libftdi for more hardcore stuff. Documentation is sparse though. Need to look at examples. For power users, one can build a custom board (PCB) with ftdi chips. There are several FTDI chips available which is able to carry out highspeed USB-3 communication.

@mpkuse
mpkuse / README.md
Last active January 26, 2021 15:50
ROS Python Snippets

ROS Python Snippets

My collection of python snippets.

  • bare_plot.py: Publish a marker message.
@mpkuse
mpkuse / ceresDummy.cpp
Last active August 7, 2018 11:15
Ceres Dummy Code.
/// Inputs : [ (x0,y0), (x1,y1), .... ].
// The loss-function is going to be the usual square-error. Which we try to minimize.
/// Will fit a linear function.
// Adopted from : https://github.com/mpkuse/advanced_techniques_for_curvefitting/blob/master/line_fitting.cpp
#include <iostream>
#include <Eigen/Core>
using namespace std;
@mpkuse
mpkuse / README.md
Last active October 26, 2018 05:16
@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 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 / 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 / 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 / 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