小编Pib*_*ben的帖子

从Swift中的CVPixelBufferRef获取像素值

如何从CVPixelBufferRef获取RGB(或任何其他格式)像素值?我尝试了很多方法,但还没有成功.

func captureOutput(captureOutput: AVCaptureOutput!,
                   didOutputSampleBuffer sampleBuffer: CMSampleBuffer!,
                   fromConnection connection: AVCaptureConnection!) {
  let pixelBuffer: CVPixelBufferRef = CMSampleBufferGetImageBuffer(sampleBuffer)!
                CVPixelBufferLockBaseAddress(pixelBuffer, 0)
  let baseAddress = CVPixelBufferGetBaseAddress(pixelBuffer)

  //Get individual pixel values here

  CVPixelBufferUnlockBaseAddress(pixelBuffer, 0)
}
Run Code Online (Sandbox Code Playgroud)

image-processing ios swift cvpixelbuffer

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

从CVPixelBufferRef获取RAW Bayer像素数据

我正在使用AVCaptureSession&AVCapturePhotoOutput以格式从设备的相机捕获RAW照片数据kCVPixelFormatType_14Bayer_RGGB.

我已经获得了AVCapturePhotoCaptureDelegate回调中的原始照片样本缓冲区:

func capture(captureOutput: AVCapturePhotoOutput,
             didFinishProcessingRawPhotoSampleBuffer rawSampleBuffer: CMSampleBuffer?,
             previewPhotoSampleBuffer: CMSampleBuffer?,
             resolvedSettings: AVCaptureResolvedPhotoSettings,
             bracketSettings: AVCaptureBracketedStillImageSettings?,
             error: Error?) {

  guard let rawSampleBuffer = rawSampleBuffer else { return }

  guard let pixelBuffer = CMSampleBufferGetImageBuffer(rawSampleBuffer) else { return }
}
Run Code Online (Sandbox Code Playgroud)

我现在正试图按照这个问题的答案来获取像素值,CVPixelBufferRef但是当使用14位拜耳RGGB像素格式而不是答案中提到的32位RGB格式时,我无法弄清楚如何做到这一点.

image-processing ios cvpixelbuffer

8
推荐指数
1
解决办法
554
查看次数

删除GCC ABI更改的注释

当我使用GCC 4.7编译我的程序时,我得到以下注释:

/usr/include/c++/4.7/backward/binders.h:167:5: note: the ABI of passing structure with complex float member has changed in GCC 4.4 here
Run Code Online (Sandbox Code Playgroud)

有没有办法摆脱它?我试图谷歌它,但我找到的只是打印注释字符串的GCC源代码行.

gcc g++

6
推荐指数
1
解决办法
3568
查看次数

使用Windows MIDI API时遇到问题(播放时无回调)

我有一个USB连接的MIDI键盘.它在其他应用程序中工作正常.但是,在我自己的程序中却没有.midiInOpen()调用通过,我得到一个回调(从打开设备)但我在播放键盘时没有得到任何回调.

通过使用midiInGetDevCaps(),我可以看到我正在使用正确的设备.

有任何想法吗?其他(商业)应用程序是否可以使用其他API?

static void CALLBACK myFunc(HMIDIIN handle, UINT uMsg,
                            DWORD dwInstance, DWORD dwParam1, DWORD dwParam2) {
   printf("Callback!"\n);
}

int main() {

   unsigned long result;
   HMIDIIN       inHandle;

   result = midiInOpen(&inHandle, 0, (DWORD)myFunc, 0, CALLBACK_FUNCTION);
   if (result)
   {
      printf("There was an error opening MIDI\n");
   }

   while(1) { Sleep(1); }
}
Run Code Online (Sandbox Code Playgroud)

c windows midi

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

具有派生类型参数的赋值运算符

class A {
private:
    A& operator=(const A&);
};

class B : public A {
public:
    B& operator=(const A&) {
            return *this;
    }
};


int main() {

    B b1;
    B b2;

    b1 = b2;

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

这给compilaton带来错误:

test.cpp: In member function 'B& B::operator=(const B&)':
test.cpp:16:5: error: 'A& A::operator=(const A&)' is private
test.cpp:19:20: error: within this context
test.cpp: In function 'int main()':
test.cpp:31:7: note: synthesized method 'B& B::operator=(const B&)'
first required here 
Build error occurred, build is stopped
Run Code Online (Sandbox Code Playgroud)

由于B :: operator …

c++ inheritance operator-overloading

2
推荐指数
1
解决办法
311
查看次数

视差值的单位是什么?

我需要一些有关视差图的帮助。

我想知道视差值的确切单位是什么?单位是像素还是毫米?

每个答案将不胜感激

computer-vision disparity-mapping photogrammetry stereoscopy

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

为什么基类需要默认构造函数?

考虑这段代码:

#include <string>

struct Float {
    float f;
    Float(float f) : f(f) {}
};

struct FloatOrString : Float {
    using Float::Float;
    std::string s;
    FloatOrString(std::string s) : s(s) {}
};


int main() {
    FloatOrString f1(1.2);
    FloatOrString f2("hello");
}
Run Code Online (Sandbox Code Playgroud)

我收到错误:

错误:“FloatOrString”的构造函数必须显式初始化没有默认构造函数的基类“Float”

为什么基类中需要默认构造函数?我怎样才能避免必须提供一个?

c++

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