Dart 将UINT8列表传递给指针<;无效>;飞镖:ffi

Dart 将UINT8列表传递给指针<;无效>;飞镖:ffi,dart,Dart,我有一个带有以下签名的C函数 bool sendFrame(int width, int height, int channelNumber, void *data, bool clone); 这里的数据是原始图像 我的ffi函数签名是: final int函数(int,int,int,Pointer,int)rPPGSendFrame=rPPGLib .查找< 本征函数< Int32函数( Int32,Int32,Int32,指针,Int32)>>(“sendFrame”) .asFunct

我有一个带有以下签名的C函数

bool sendFrame(int width, int height, int channelNumber, void *data, bool clone);
这里的数据是原始图像

我的ffi函数签名是:

final int函数(int,int,int,Pointer,int)rPPGSendFrame=rPPGLib
.查找<
本征函数<
Int32函数(
Int32,Int32,Int32,指针,Int32)>>(“sendFrame”)
.asFunction();
(bool必须转换为int,因为bool类型还不受支持(对吗?)

我试图从dart调用此方法,其中
Uint8List
来自摄影机流的一帧,但我不确定如何将我的
Uint8List
转换/分配到
void*

有什么想法吗


干杯

> P>我不确定你是否仍然有这个问题,但是我最近发现了一种方法,将图像数据流从API到C++。 2020/01/08更新

这里可以找到一个工作示例。警告:这里有一个问题目前正在调查中

初始答案

我的设置: 颤振(通道测试版,v1.12.13+修补程序6) •颤振版本1.12.13+修补程序。6 •框架版本18cd7a3601(30小时前),2019-12-11 06:35:39-0800 •发动机版本2994f7e1e6 •Dart版本2.7.0 外国金融机构版本0.1.3()

在颤振代码中,使用以下内容准备图像数据:

import "dart:ffi" as ffi;

// 'data' is a Uint8List created by concatenating the planes received from the CameraImage the camera puts out.
// Based on the code found here https://github.com/renancaraujo/bitmap/blob/master/lib/ffi.dart in the execute function
// https://groups.google.com/forum/#!searchin/dart-ffi/list%7Csort:date/dart-ffi/V_6g5hpABec/U9we6UyvBAAJ
  final ffi.Pointer<ffi.Uint8> frameData = allocate<ffi.Uint8>(count: data.length); // Allocate a pointer large enough.
  final pointerList = frameData.asTypedList(data.length); // Create a list that uses our pointer and copy in the image data.
  pointerList.setAll(0, data);

C++函数看起来是这样的:

extern "C" {
__attribute__((visibility("default"))) __attribute__((used))
    int cppFunc(unsigned char *data, int width, int height, int scanline) {
.
.
.
我不知道随着dart:ffi向1.0发展,这是否会继续有效,但我会尽量让这个答案保持最新

extern "C" {
__attribute__((visibility("default"))) __attribute__((used))
    int cppFunc(unsigned char *data, int width, int height, int scanline) {
.
.
.