gpt4 book ai didi

C# vuforia.image.pixels 覆盖到 iOS CIImage 或 CGImage

转载 作者:行者123 更新时间:2023-11-29 11:45:16 25 4
gpt4 key购买 nike

C#

private Vuforia.Image QCARoutput;
QCARoutput = CameraDevice.Instance.GetCameraImage(Vuforia.Image.PIXEL_FORMAT.RGB888);

_iOS_sendData(QCARoutput.Pixels, QCARoutput.Pixels.length);

iOS

void _iOS_sendData(const char** ptrSrc, const int srcLength) {

NSData *imageData = [NSData dataWithBytes:(const void *)ptrSrc length:(sizeof(unsigned char) * srcLength)];
CIImage *ciimg = [CIImage imageWithData:imageData];
[delegateObject decodeWithQRcode:ciimg complete:^(NSString *result) {
NSLog(@"%@",result);
}];
}

所以我想得到 Vuforia.image.pixels,它是 byte[]。然后发送到 iOS 覆盖到 CIImage,但 ciimage 为 null。我如何将这个 byte[] 覆盖到 CIImage 对象?

====== 更新 C# ======

[DllImport("__Internal")]
private static extern void _iOS_sendData_ResultBlock(System.IntPtr ptrSrc, int srcLength);

//=================================================
QCARoutput = CameraDevice.Instance.GetCameraImage(Vuforia.Image.PIXEL_FORMAT.RGB888);
IntPtr unmanagedPointer = Marshal.AllocHGlobal(QCARoutput.Pixels.Length);
Marshal.Copy(QCARoutput.Pixels, 0, unmanagedPointer, QCARoutput.Pixels.Length);
// Call unmanaged code
Marshal.FreeHGlobal(unmanagedPointer);
_iOS_sendData_ResultBlock(unmanagedPointer, QCARoutput.Pixels.Length);

====== 更新 Objective-C ======

void _iOS_sendData_ResultBlock(Byte *ptrSrc, const int srcLength, iOSUnityCallBack callback) {

NSData *imageData = [NSData dataWithBytes:ptrSrc length:(sizeof(unsigned char) * srcLength)];
CIImage *ciimg = [CIImage imageWithData:imageData];
if (ciimg == nil) {
NSLog(@"the ciimage is nil ,stop");
return;
}
}

我做了一些改变。它不起作用。

最佳答案

我认为您需要在 C# 和 obj-c 两边更改 _iOS_sendData 的声明。我猜你有这样的事情:

//c# side
[DllImport ("__Internal")]
private static extern void _iOS_sendData(byte[] bytes, int length);

不知道为什么,但是 bytes 参数必须是一个数组指针,而不是一个实际的数组。我认为这是因为 Objective-C 处理事情的方式。

尝试以下操作:

//c# side
[DllImport ("__Internal")]
private static extern void _iOS_sendData(System.IntPtr bytes, int length);

//obj-c side
void _iOS_sendData(Byte * bytes, int length)

source

关于C# vuforia.image.pixels 覆盖到 iOS CIImage 或 CGImage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44301659/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com