gpt4 book ai didi

java - cvtColor 崩溃 android

转载 作者:行者123 更新时间:2023-12-02 12:10:46 33 4
gpt4 key购买 nike

我一直在尝试进入 OpenCV。下面的代码似乎在 cvtColor 上崩溃了。

    public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
mRgba = inputFrame.rgba();
mGray = inputFrame.gray();

Mat gray = new Mat();
Imgproc.cvtColor(mRgba, gray, Imgproc.COLOR_RGB2GRAY);

return gray;
}

我无法解释为什么在视频运行 10 秒后 Android 应用程序不断崩溃,没有 cvtColor 它运行得很好。

想知道这里会发生什么。

日志

 ExynosCameraBufferManager: [CAM_ID(0)][ISP_BUF]-ERR(getBuffer[667]):increase the buffer failed, m_allocatedBufCount 8, bufferIndex -2
10-04 20:39:54.877 3105 22149 E ExynosCameraMCPipe: [CAM_ID(0)][PIPE_3AA]-ERR(m_putBuffer[1447]):Buffer manager getBuffer fail, manager(2), frameCount(686), ret(-22)
10-04 20:39:54.936 3105 22149 E ExynosCameraBufferManager: [CAM_ID(0)][ISP_BUF]-ERR(getBuffer[667]):increase the buffer failed, m_allocatedBufCount 8, bufferIndex -2
10-04 20:39:54.936 3105 22149 E ExynosCameraMCPipe: [CAM_ID(0)][PIPE_3AA]-ERR(m_putBuffer[1447]):Buffer manager getBuffer fail, manager(2), frameCount(687), ret(-22)
10-04 20:39:54.996 3105 22149 E ExynosCameraBufferManager: [CAM_ID(0)][ISP_BUF]-ERR(getBuffer[667]):increase the buffer failed, m_allocatedBufCount 8, bufferIndex -2
10-04 20:39:54.996 3105 22149 E ExynosCameraMCPipe: [CAM_ID(0)][PIPE_3AA]-ERR(m_putBuffer[1447]):Buffer manager getBuffer fail, manager(2), frameCount(688), ret(-22)
10-04 20:39:55.055 3105 22150 E ExynosCameraMCPipe: [CAM_ID(0)][PIPE_3AA]-ERR(m_getBuffer[1948]):frameCount(686) : captureNodeCount == 0 || checkRet(0) != NO_ERROR. so, setFrameState(FRAME_STATE_SKIPPED)
10-04 20:39:55.056 3105 22149 E ExynosCameraBufferManager: [CAM_ID(0)][ISP_BUF]-ERR(getBuffer[667]):increase the buffer failed, m_allocatedBufCount 8, bufferIndex -2
10-04 20:39:55.056 3105 22149 E ExynosCameraMCPipe: [CAM_ID(0)][PIPE_3AA]-ERR(m_putBuffer[1447]):Buffer manager getBuffer fail, manager(2), frameCount(689), ret(-22)
10-04 20:39:55.056 25883 25883 E CocktailBarContainerView: updateContainerVisibility: 0
10-04 20:39:55.115 3105 22150 E ExynosCameraMCPipe: [CAM_ID(0)][PIPE_3AA]-ERR(m_getBuffer[1948]):frameCount(687) : captureNodeCount == 0 || checkRet(0) != NO_ERROR. so, setFrameState(FRAME_STATE_SKIPPED)
10-04 20:39:55.116 3105 22149 E ExynosCameraBufferManager: [CAM_ID(0)][ISP_BUF]-ERR(getBuffer[667]):increase the buffer failed, m_allocatedBufCount 8, bufferIndex -2
10-04 20:39:55.116 3105 22149 E ExynosCameraMCPipe: [CAM_ID(0)][PIPE_3AA]-ERR(m_putBuffer[1447]):Buffer manager getBuffer fail, manager(2), frameCount(690), ret(-22)
10-04 20:39:55.131 25883 25883 E CocktailBarContainerView: updateContainerVisibility: 0
10-04 20:39:55.131 25883 25883 E CocktailBarPanelManager: updateCocktailDisplayPolicy: 128 ---> 128
10-04 20:39:55.131 25883 25883 E CocktailBarContainerView: updateContainerVisibility: 0
10-04 20:39:55.135 25883 25883 E CocktailBarContainerView: updateContainerVisibility: 0
10-04 20:39:55.158 26076 26076 E Zygote : v2
10-04 20:39:55.160 26076 26076 E Zygote : accessInfo : 0
10-04 20:39:55.176 3105 22150 E ExynosCameraMCPipe: [CAM_ID(0)][PIPE_3AA]-ERR(m_getBuffer[1948]):frameCount(688) : captureNodeCount == 0 || checkRet(0) != NO_ERROR. so, setFrameState(FRAME_STATE_SKIPPED)
10-04 20:39:55.176 3105 22149 E ExynosCameraBufferManager: [CAM_ID(0)][ISP_BUF]-ERR(getBuffer[667]):increase the buffer failed, m_allocatedBufCount 8, bufferIndex -2
10-04 20:39:55.176 3105 22149 E ExynosCameraMCPipe: [CAM_ID(0)][PIPE_3AA]-ERR(m_putBuffer[1447]):Buffer manager getBuffer fail, manager(2), frameCount(691), ret(-22)
10-04 20:39:55.183 25883 25883 E CocktailBarPanelManager: updateCocktailDisplayPolicy: 128 ---> 1
10-04 20:39:55.184 25883 25883 E CocktailBarContainerView: updateContainerVisibility: 0
10-04 20:39:55.186 26087 26087 E Zygote : v2
10-04 20:39:55.187 26087 26087 E Zygote : accessInfo : 0
10-04 20:39:55.205 3105 26008 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
10-04 20:39:55.210 3105 22157 E Surface : queueBuffer: error queuing buffer to SurfaceTexture, -32
10-04 20:39:55.210 3105 26008 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
10-04 20:39:55.210 3105 22157 E ExynosCameraMemoryAllocator: ERR(enqueueBuffer):enqueue_buffer failed
10-04 20:39:55.210 3105 26008 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
10-04 20:39:55.210 3105 22157 E ExynosCameraBufferManager: [CAM_ID(0)][SCP_BUF]-ERR(m_putBuffer[1866]):could not enqueue_buffer [bufIndex=1]
10-04 20:39:55.210 3105 26008 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
10-04 20:39:55.210 3105 26008 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
10-04 20:39:55.210 3105 26008 E ExynosCameraMemoryAllocator: @@@@ERR(alloc):*bufHandle == NULL failed
10-04 20:39:55.210 3105 26008 E ExynosCameraMemoryAllocator: ERR(dequeueBuffer):alloc failed
10-04 20:39:55.210 3105 26008 E ExynosCameraBufferManager: [CAM_ID(0)][SCP_BUF]-ERR(m_bufferCollectorThreadFunc[2294]):dequeueBuffer failed, dequeue(6), collected(4)
10-04 20:39:55.214 3105 26102 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
10-04 20:39:55.214 3105 26102 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
10-04 20:39:55.214 3105 26102 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
10-04 20:39:55.214 3105 26102 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
10-04 20:39:55.214 3105 26102 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
10-04 20:39:55.214 3105 26102 E ExynosCameraMemoryAllocator: @@@@ERR(alloc):*bufHandle == NULL failed
10-04 20:39:55.214 3105 26102 E ExynosCameraMemoryAllocator: ERR(dequeueBuffer):alloc failed
10-04 20:39:55.215 3105 26102 E ExynosCameraBufferManager: [CAM_ID(0)][SCP_BUF]-ERR(m_bufferCollectorThreadFunc[2294]):dequeueBuffer failed, dequeue(6), collected(3)
10-04 20:39:55.217 3105 22151 E ExynosCameraMCPipe: [CAM_ID(0)][PIPE_ISP]-ERR(m_putBuffer[1420]):Pipe is Busy, Skip frame, frameCount(679)
10-04 20:39:55.219 3105 26103 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
10-04 20:39:55.219 3105 26103 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
10-04 20:39:55.219 3105 26103 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
10-04 20:39:55.219 3105 26103 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
10-04 20:39:55.219 3105 26103 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
10-04 20:39:55.219 3105 26103 E ExynosCameraMemoryAllocator: @@@@ERR(alloc):*bufHandle == NULL failed
10-04 20:39:55.219 3105 26103 E ExynosCameraMemoryAllocator: ERR(dequeueBuffer):alloc failed
10-04 20:39:55.219 3105 26103 E ExynosCameraBufferManager: [CAM_ID(0)][SCP_BUF]-ERR(m_bufferCollectorThreadFunc[2294]):dequeueBuffer failed, dequeue(6), collected(2)
10-04 20:39:55.223 3105 26104 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
10-04 20:39:55.223 3105 22157 E Surface : queueBuffer: error queuing buffer to SurfaceTexture, -32
10-04 20:39:55.223 3105 22157 E ExynosCameraMemoryAllocator: ERR(enqueueBuffer):enqueue_buffer failed
10-04 20:39:55.224 3105 26104 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
10-04 20:39:55.224 3105 22157 E ExynosCameraBufferManager: [CAM_ID(0)][SCP_BUF]-ERR(m_putBuffer[1866]):could not enqueue_buffer [bufIndex=2]
10-04 20:39:55.224 3105 26104 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
10-04 20:39:55.224 3105 26104 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
10-04 20:39:55.224 3105 26104 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
10-04 20:39:55.224 3105 26104 E ExynosCameraMemoryAllocator: @@@@ERR(alloc):*bufHandle == NULL failed
10-04 20:39:55.224 3105 26104 E ExynosCameraMemoryAllocator: ERR(dequeueBuffer):alloc failed
10-04 20:39:55.224 3105 26104 E ExynosCameraBufferManager: [CAM_ID(0)][SCP_BUF]-ERR(m_bufferCollectorThreadFunc[2294]):dequeueBuffer failed, dequeue(6), collected(1)
10-04 20:39:55.225 3105 26105 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
10-04 20:39:55.225 3105 26105 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
10-04 20:39:55.225 3105 22151 E ExynosCameraBufferManager: [CAM_ID(0)][SCP_BUF]-ERR(m_getCollectedBuffer[2397]):Gralloc buffer collector has no Buffer
10-04 20:39:55.225 3105 26105 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
10-04 20:39:55.225 3105 22151 E ExynosCameraBufferManager: [CAM_ID(0)][SCP_BUF]-ERR(m_getCollectedBuffer[2421]):Failed to get available gralloc buffer from buffer collector, available count(0)
10-04 20:39:55.225 3105 26105 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
10-04 20:39:55.226 3105 22151 E ExynosCameraBufferManager: [CAM_ID(0)][SCP_BUF]-ERR(getBuffer[611]):m_getBuffer failed [bufferIndex=-2, position=2, permission=0]
10-04 20:39:55.226 3105 26105 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
10-04 20:39:55.226 3105 22151 E ExynosCameraMCPipe: [CAM_ID(0)][PIPE_ISP]-ERR(m_putBuffer[1447]):Buffer manager getBuffer fail, manager(5), frameCount(683), ret(-38)
10-04 20:39:55.226 3105 26105 E ExynosCameraMemoryAllocator: @@@@ERR(alloc):*bufHandle == NULL failed
10-04 20:39:55.226 3105 26105 E ExynosCameraMemoryAllocator: ERR(dequeueBuffer):alloc failed
10-04 20:39:55.226 3105 26105 E ExynosCameraBufferManager: [CAM_ID(0)][SCP_BUF]-ERR(m_bufferCollectorThreadFunc[2294]):dequeueBuffer failed, dequeue(6), collected(0)
10-04 20:39:55.226 3105 22151 E ExynosCameraBufferManager: [CAM_ID(0)][SCP_BUF]-ERR(m_getCollectedBuffer[2397]):Gralloc buffer collector has no Buffer
10-04 20:39:55.226 3105 22151 E ExynosCameraBufferManager: [CAM_ID(0)][SCP_BUF]-ERR(m_getCollectedBuffer[2421]):Failed to get available gralloc buffer from buffer collector, available count(0)
10-04 20:39:55.226 3105 22151 E ExynosCameraBufferManager: [CAM_ID(0)][SCP_BUF]-ERR(getBuffer[611]):m_getBuffer failed [bufferIndex=-2, position=2, permission=0]
10-04 20:39:55.226 3105 22151 E ExynosCameraMCPipe: [CAM_ID(0)][PIPE_ISP]-ERR(m_putBuffer[1447]):Buffer manager getBuffer fail, manager(5), frameCount(684), ret(-38)
10-04 20:39:55.226 3105 22151 E ExynosCameraBufferManager: [CAM_ID(0)][SCP_BUF]-ERR(m_getCollectedBuffer[2397]):Gralloc buffer collector has no Buffer
10-04 20:39:55.226 3105 26107 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
10-04 20:39:55.226 3105 22151 E ExynosCameraBufferManager: [CAM_ID(0)][SCP_BUF]-ERR(m_getCollectedBuffer[2421]):Failed to get available gralloc buffer from buffer collector, available count(0)
10-04 20:39:55.226 3105 22151 E ExynosCameraBufferManager: [CAM_ID(0)][SCP_BUF]-ERR(getBuffer[611]):m_getBuffer failed [bufferIndex=-2, position=2, permission=0]
10-04 20:39:55.226 3105 22151 E ExynosCameraMCPipe: [CAM_ID(0)][PIPE_ISP]-ERR(m_putBuffer[1447]):Buffer manager getBuffer fail, manager(5), frameCount(685), ret(-38)
10-04 20:39:55.226 3105 26107 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
10-04 20:39:55.226 3105 26107 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
10-04 20:39:55.226 3105 26107 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
10-04 20:39:55.226 3105 26107 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
10-04 20:39:55.226 3105 26107 E ExynosCameraMemoryAllocator: @@@@ERR(alloc):*bufHandle == NULL failed
10-04 20:39:55.226 3105 26107 E ExynosCameraMemoryAllocator: ERR(dequeueBuffer):alloc failed
10-04 20:39:55.227 3105 26107 E ExynosCameraBufferManager: [CAM_ID(0)][SCP_BUF]-ERR(m_bufferCollectorThreadFunc[2294]):dequeueBuffer failed, dequeue(6), collected(0)
10-04 20:39:55.227 3105 22151 E ExynosCameraMCPipe: [CAM_ID(0)][PIPE_ISP]-ERR(m_putBuffer[1410]):New frame is INVALID, frameCount(686)
10-04 20:39:55.227 3105 22151 E ExynosCameraMCPipe: [CAM_ID(0)][PIPE_ISP]-ERR(m_putBuffer[1410]):New frame is INVALID, frameCount(687)
10-04 20:39:55.227 3105 22151 E ExynosCameraMCPipe: [CAM_ID(0)][PIPE_ISP]-ERR(m_putBuffer[1410]):New frame is INVALID, frameCount(688)
10-04 20:39:55.236 3105 3382 E CameraService: notifyError(CAMERA_MSG_ERROR, CAMERA_ERROR_RELEASED)
10-04 20:39:55.236 3105 22150 E ExynosCameraMCPipe: [CAM_ID(0)][PIPE_3AA]-ERR(m_getBuffer[1948]):frameCount(689) : captureNodeCount == 0 || checkRet(0) != NO_ERROR. so, setFrameState(FRAME_STATE_SKIPPED)
10-04 20:39:55.236 3105 22151 E ExynosCameraMCPipe: [CAM_ID(0)][PIPE_ISP]-ERR(m_putBuffer[1410]):New frame is INVALID, frameCount(689)
10-04 20:39:55.243 3105 22157 E Surface : queueBuffer: error queuing buffer to SurfaceTexture, -32
10-04 20:39:55.243 3105 22157 E ExynosCameraMemoryAllocator: ERR(enqueueBuffer):enqueue_buffer failed
10-04 20:39:55.243 3105 22157 E ExynosCameraBufferManager: [CAM_ID(0)][SCP_BUF]-ERR(m_putBuffer[1866]):could not enqueue_buffer [bufIndex=3]
10-04 20:39:55.260 3105 22157 E Surface : queueBuffer: error queuing buffer to SurfaceTexture, -32
10-04 20:39:55.260 3105 22157 E ExynosCameraMemoryAllocator: ERR(enqueueBuffer):enqueue_buffer failed
10-04 20:39:55.260 3105 22157 E ExynosCameraBufferManager: [CAM_ID(0)][SCP_BUF]-ERR(m_putBuffer[1866]):could not enqueue_buffer [bufIndex=4]
10-04 20:39:55.288 3105 22157 E Surface : queueBuffer: error queuing buffer to SurfaceTexture, -32
10-04 20:39:55.288 3105 22157 E ExynosCameraMemoryAllocator: ERR(enqueueBuffer):enqueue_buffer failed
10-04 20:39:55.288 3105 22157 E ExynosCameraBufferManager: [CAM_ID(0)][SCP_BUF]-ERR(m_putBuffer[1866]):could not enqueue_buffer [bufIndex=5]
10-04 20:39:55.296 3105 22150 E ExynosCameraMCPipe: [CAM_ID(0)][PIPE_3AA]-ERR(m_getBuffer[1948]):frameCount(690) : captureNodeCount == 0 || checkRet(0) != NO_ERROR. so, setFrameState(FRAME_STATE_SKIPPED)
10-04 20:39:55.296 3105 22151 E ExynosCameraMCPipe: [CAM_ID(0)][PIPE_ISP]-ERR(m_putBuffer[1410]):New frame is INVALID, frameCount(690)
10-04 20:39:55.317 3105 22157 E Surface : queueBuffer: error queuing buffer to SurfaceTexture, -32
10-04 20:39:55.317 3105 22157 E ExynosCameraMemoryAllocator: ERR(enqueueBuffer):enqueue_buffer failed
10-04 20:39:55.317 3105 22157 E ExynosCameraBufferManager: [CAM_ID(0)][SCP_BUF]-ERR(m_putBuffer[1866]):could not enqueue_buffer [bufIndex=6]
10-04 20:39:55.343 3105 22152 E ExynosCameraMCPipe: [CAM_ID(0)][PIPE_ISP]-ERR(m_getBuffer[1948]):frameCount(683) : captureNodeCount == 0 || checkRet(0) != NO_ERROR. so, setFrameState(FRAME_STATE_SKIPPED)
10-04 20:39:55.356 3105 22150 E ExynosCameraMCPipe: [CAM_ID(0)][PIPE_3AA]-ERR(m_getBuffer[1948]):frameCount(691) : captureNodeCount == 0 || checkRet(0) != NO_ERROR. so, setFrameState(FRAME_STATE_SKIPPED)
10-04 20:39:55.419 3105 3382 E Surface : IGraphicBufferProducer::setBufferCount(0) returned Broken pipe
10-04 20:39:55.419 3105 3382 E ExynosCameraMemoryAllocator: ERR(setBufferCount):set_buffer_count failed [bufCount=0]
10-04 20:39:55.419 3105 3382 E ExynosCameraBufferManager: [CAM_ID(0)][SCP_BUF]-ERR(setBufferCount[2206]):m_allocator->setBufferCount(m_bufferCount(9)

-> 0)

看起来相机缓冲区在某个时刻消失了,认为这就是日志中发生的情况。

谢谢

最佳答案

似乎问题出在

Mat gray = new Mat();

line,因为它会在每个新相机帧上创建新的Mat。尝试将 Gray 变量设置为全局变量,并在 onCameraViewStarted() 中创建一次,然后将其用作 Imgproc.cvtColor() 参数。类似这样的事情:

public class MainActivity extends AppCompatActivity implements CameraBridgeViewBase.CvCameraViewListener2 {
private Mat mRgba;
private Mat mGray;

...

@Override
public void onCameraViewStarted(int width, int height) {
mGray = new Mat(height, width, CvType.CV_8U);
}

...

@Override
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
mRgba = inputFrame.rgba();
Imgproc.cvtColor(mRgba, mGray, Imgproc.COLOR_RGB2GRAY);
return mGray;
}

...

}

关于java - cvtColor 崩溃 android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46567420/

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