小编Yae*_*ger的帖子

如何远程处理(低延迟)Raspicam输出?

由于Raspberry Pi的处理能力有限,我需要在远程机器上处理相机输出.本机是Linux服务器,应使用OpenCV处理视频数据.

我发现了一种技术上可行的解决方案,但在1280x720分辨率下产生大约10秒的不可接受的高延迟,在640x360分辨率下产生大约17秒的高延迟.也许这是由于某些缓冲区大小太大造成的?

那么,到目前为止我的解决方案

在Raspberry PI上首先使用raspivid命令捕获视频,将此数据输出到标准输出并使用netcat进行传输:

raspivid --timeout 0 --nopreview --intra 2 --width 1280 --height 720 --framerate 20 --output - | nc 192.168.1.108 5555
Run Code Online (Sandbox Code Playgroud)

然后在接收部分(实际上在发送之前调用):

nc -l -p 5555 | ./receiver
Run Code Online (Sandbox Code Playgroud)

其中receiver是一个带有以下源代码的C++应用程序:

#include <opencv2/highgui/highgui.hpp>
#include <iostream>

int main()
{
    cv::VideoCapture cap("/dev/stdin");

    if(!cap.isOpened())
    {
        std::cout << "Could not open '/dev/stdin'!" << std::endl;
        return -1;
    }

    cv::namedWindow("Receiver");
    cv::Mat frame;

    while(cap.read(frame))
    {
        cv::imshow("Receiver", frame);
        cv::waitKey(30);
    }

    cv::waitKey(0);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

如何将raspicam输出传输到(Linux)服务器,并能够使用支持OpenCV的C++应用程序处理此数据.在帧的传输和该帧的实际处理之间需要低等待时间(<400ms是可接受的).

编辑:还需要高分辨率(1280x720或更高).

请原谅我的英文,如果有任何错误!

linux opencv netcat raspberry-pi

5
推荐指数
1
解决办法
1218
查看次数

根据上下文翻译句子的一部分

我正在开发一个需要能够翻译部分句子的应用程序。问题是,如果我将这些部分发送到像 Google Translate 这样的翻译 API,这些翻译在它们发生的上下文中通常没有意义。例如:

离开大楼

如果我将叶子翻译成任何目标语言,我可能会在“树叶”的上下文中得到结果,这在示例中当然没有意义。因此,翻译需要考虑上下文。如果我展开翻译句子他的叶子,我得到的正确翻译他的叶子。但是,我丢失了的翻译,这是我正在寻找的词。

有没有人知道我应该如何处理这个问题?请记住,Google Translate API 是付费 API,因此我希望尽量减少从 API 请求的翻译量。

machine-translation

3
推荐指数
1
解决办法
1032
查看次数

C++ 我应该如何返回我的字节数组?

我有一个名为 X(例如)的类和一个公共函数 toBytes(),它返回对象的一些自定义二进制表示。

我的问题是:我应该如何返回这个字节数组?

目前,我有这个:

uint8_t* X::toBytes()
{
    uint8_t* binData = new uint8_t[...];

    // initialize the byte array

    return binData;
}
Run Code Online (Sandbox Code Playgroud)

The problem (or as problem considered by me as an inexperienced c++ programmer) here is that it's allocating the memory on the heap and should be freed at some point which I don't think is practical. Either the class X should free this memory in its destructor in some cumbersome way or the caller should free it. How is …

c++ memory arrays heap-memory

0
推荐指数
1
解决办法
1847
查看次数