Skip to content

Instantly share code, notes, and snippets.

View mpkuse's full-sized avatar

Manohar Kuse mpkuse

View GitHub Profile
@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 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 / 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 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 / rosbag_to_image.py
Created December 14, 2018 09:53
ROS bag to images
import rosbag
from cv_bridge import CvBridge, CvBridgeError
import cv2
# Input : A ros-bag
# Output : Save the image msg as individual images. Edit as appropriate.
bag = rosbag.Bag('banana.bag')
for topic, msg, t in bag.read_messages(topics=['/mynteye/right/image_raw']):
# print msg
@mpkuse
mpkuse / 1_pyserial.py
Last active January 31, 2019 11:10
NMEA0183 (GPS) and Python
import serial
import pynmea2
import collections
def signal_handle( sig, frame ):
# Save JSON
import json
with open( '/home/mpkuse/try/gps_nmea/data.json', 'w' ) as outfile:
json.dump( ARY, outfile )
exit(0)
@mpkuse
mpkuse / 1-Flat.cpp
Last active May 17, 2019 03:14
Linking faiss in your Cmake projects
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD+Patents license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <cstdio>
#include <cstdlib>
@mpkuse
mpkuse / ImageNetLabels.cpp
Created June 3, 2019 09:31
ImageNet Labels C++ Class
#pragma once
#include <iostream>
#include <string>
class ImageNetLabels {
public:
ImageNetLabels()
{
@mpkuse
mpkuse / README.md
Last active June 6, 2019 02:16
tx2 load keras model with custom layer
import cv2
import numpy as np
def convert_3x3_1x1__to__4x4(fname, outfname, outvarname ):
## READ YAML OPENCV
print( 'fname: ', fname )
fs = cv2.FileStorage(fname, cv2.FILE_STORAGE_READ)