亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Android 上的 OpenCV:net.forward 產生“215 斷言失敗”

Android 上的 OpenCV:net.forward 產生“215 斷言失敗”

楊魅力 2023-05-24 15:18:45
因 net.forward 上的斷言失敗而崩潰,我無法在其他任何地方解決/找到。認為這個問題看起來很相似,并試圖通過修復/問題發現。然而,重新開始討論和試驗表明它可能不一樣。我最初使用的是 3.4.3,它以某種方式不支持相同的 Mat 類型?,F在更新到 3.4.7,可以確認 blob 大小沒問題(從圖像生成)。還嘗試了其他各種 prototxt 和 caffemodels,但現在懷疑問題出在那里(如果文件沒問題就可以工作,否則網絡加載失?。?。關鍵代碼應該是這樣的:// Load a network.public void onCameraViewStarted(int width, int height) {? ? String proto = getPath("deploy.prototxt", this);? ? String weights = getPath("MobileNetSSD_deploy.caffemodel", this);? ? net = Dnn.readNetFromCaffe(proto, weights);? ? Log.i(TAG, "Network loaded successfully");}public Mat onCameraFrame(CvCameraViewFrame inputFrame) {? ? // Get a new frame? ? Mat frame = inputFrame.rgba();? ? Imgproc.cvtColor(frame, frame, Imgproc.COLOR_RGBA2RGB);? ? // Forward image through network.? ? Mat blob = Dnn.blobFromImage(frame, 0.007843,? ? ? ? ? ? new Size(300, 300),? ? ? ? ? ? new Scalar(127.5, 127.5, 127.5));? ? net.setInput(blob);? ? Mat detections = net.forward(); //***215 ASSERTION FAILED occurs***? ? int cols = frame.cols();? ? int rows = frame.rows();? ? detections = detections.reshape(1, (int)detections.total() / 7);? ? for (int i = 0; i < detections.rows(); ++i) {? ? ? ? double confidence = detections.get(i, 2)[0];? ? ? ? if (confidence > 0.2) {? ? ? ? ? ? int classId = (int)detections.get(i, 1)[0];? ? ? ? ? ? int left? ?= (int)(detections.get(i, 3)[0] * cols);? ? ? ? ? ? int top? ? = (int)(detections.get(i, 4)[0] * rows);? ? ? ? ? ? int right? = (int)(detections.get(i, 5)[0] * cols);? ? ? ? ? ? int bottom = (int)(detections.get(i, 6)[0] * rows);? ? ? ? }? ? }? ? return frame;}完整的錯誤信息是cv::Exception: OpenCV(3.4.7) /build/3_4_pack-android/opencv/modules/dnn/src/layers/batch_norm_layer.cpp:39: 錯誤: (-215:斷言失敗) blobs.size() >= 2 在函數 'cv::dnn::BatchNormLayerImpl::BatchNormLayerImpl(const cv::dnn::experimental_dnn_34_v13::LayerParams&)'我希望它不會崩潰??蚣軕摏]問題(圖像已加載),網絡不是空的,網絡中的層看起來也很好(已檢查,因為在 java 中使用 caffe 存在一些差異)。任何幫助表示贊賞!
查看完整描述

1 回答

?
溫溫醬

TA貢獻1752條經驗 獲得超4個贊

幀格式應該是 BGR,而不是 RGB!這意味著

Imgproc.cvtColor(frame,?frame,?Imgproc.COLOR_RGBA2BGR);


查看完整回答
反對 回復 2023-05-24
  • 1 回答
  • 0 關注
  • 321 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號