My collection of python snippets.
- bare_plot.py: Publish a marker message.
/// 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; |
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.
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'.
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 |
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) |
/** | |
* 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> |
#pragma once | |
#include <iostream> | |
#include <string> | |
class ImageNetLabels { | |
public: | |
ImageNetLabels() | |
{ |
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) |