Skip to content

Instantly share code, notes, and snippets.

@fernandoc1
fernandoc1 / main.cpp
Created January 25, 2019 14:36
QProcess::finished with lambda function example.
#include <QCoreApplication>
#include <QtGlobal>
#include <QDebug>
#include "global_settings.hpp"
int main(int argc, char** argv)
{
QCoreApplication app(argc, argv);
@fernandoc1
fernandoc1 / Makefile
Created March 1, 2019 20:18
This code plays sound of shapes
all:
g++ morph_descriptor.cpp -o MorphDescriptor -lao -lopencv_core -lopencv_highgui -lopencv_imgproc
@fernandoc1
fernandoc1 / python_test.cpp
Created April 23, 2019 14:29
Access std::vector in boost::python
#include <iostream>
#include <vector>
#include <memory>
#include <boost/shared_ptr.hpp>
#include <boost/python.hpp>
#include <boost/python/stl_iterator.hpp>
#include <Python.h>
template<typename T> inline std::vector<T> pyListToStdVector(const boost::python::object& iterable)
{
@fernandoc1
fernandoc1 / test.html
Created September 12, 2019 19:45
This code tests CGI with C++ and javascript fetch function.
<html>
<body>
</body>
</html>
<script>
async function loadData()
{
let response = await fetch("http://localhost/path/to/TestCGI.bin", {
method: 'POST',
@fernandoc1
fernandoc1 / timer_example.cpp
Last active September 19, 2019 19:43
This is a timer thread example with a lambda function and std::condition_variable.
#include <iostream>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <unistd.h>
int main(int argc, char** argv)
{
std::mutex m;
@fernandoc1
fernandoc1 / extract_roi.cpp
Created September 24, 2019 21:53
This extracts a ROI from images that are 16bits per pixel.
void extractRoi(cv::Mat& inImage, cv::Mat& outImage, cv::Rect roi)
{
/* Create the image */
outImage = cv::Mat(roi.height, roi.width, inImage.type());
/* Populate the image */
for (int i = roi.y; i < (roi.y+roi.height); i++)
{
uint16_t* inP = inImage.ptr<uint16_t>(i);
uint16_t* outP = outImage.ptr<uint16_t>(i-roi.y);