Skip to content

QuickDataFlow library is designed for messaging between programs written in c++ and python

License

Notifications You must be signed in to change notification settings

ilyajob05/QuickDataFlow

Repository files navigation

QuickDataFlow

Build Status codecov Quality Gate Status CMake License PyPI

This library is for building multithreaded and fast C++ applications

Requirements

  • gtest
  • wheel

Install

Build for C++

git clone https://github.com/ilyajob05/QuickDataFlow.git
cd QuickDataFlow
chmod +x build.sh
./build.sh

Install from deb

Your need build library before install

sudo pdkg -i build/QuickDataFlow-2.1.0-Linux.deb

Install from Pypi

pip install QuickDataFlow

or download file from PyPi whl or tar.gz

pip install QuickDataFlow-2.1.2.tar.gz 
# or
# pip install QuickDataFlow-2.1.2-cp310-cp310-manylinux2014_x86_64.whl 

Usage

C++

#include <opencv2/opencv.hpp>
#include "shm_message.hpp"

using namespace fshm;
using namespace std;
using namespace cv;

int main(int argc, char* argv[])
{
    // create a buffer for data transfer
    MessageBuff msg_buff("img_sender_point_i_", "img_sender_point_o_",
                         10, 10, 640 * 480 * 3, 640 * 480 * 3);
    Mat inputImage = imread("../data/test-image-1.png");
    Mat sendImage(480, 640, CV_8UC3);
    resize(inputImage, sendImage, Size(640, 480));
    cvtColor(sendImage, sendImage, COLOR_BGR2RGB); // for PIL
    namedWindow("camera image sender", WINDOW_NORMAL);
    // send data
    uchar* arr = sendImage.isContinuous() ? sendImage.data : sendImage.clone().data;
    msg_buff.push_message_sync(static_cast<unsigned char*>(arr));
    imshow("camera image sender", inputImage);
    waitKey(10000);
    return 0;
}

Python

from PIL import Image
from QuickDataFlow import shm_message as sm

mb_buff = sm.MessageBuff("img_sender_point_o_", "img_sender_point_i_",
                         10, 10, 640 * 480 * 3, 640 * 480 * 3)
buff = bytes([0] * (640 * 480 * 3))
mb_buff.get_msg(buff)
img = Image.frombytes("RGB", (640,480), buff)
img.show()