<h5 dir="auto">System information (version)</h5>

<ul dir="auto">
<li>OpenCV =&gt; 4.1.1</li>
<li>Operating System / Platform =&gt; Ubuntu 18.04</li>
<li>Compiler =&gt; gcc</li>
</ul>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">When I load the onnx model (converted from pytorch ) using cv::dnn::readNetFromONNX from memory buffer, it will get the "error: (-210:Unsupported format or combination of formats) Failed to parse onnx model from in-memory byte array. in function 'ONNXImporter'".</p>
<h5 dir="auto">Steps to reproduce</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="```
ifstream modelStream(&quot;../model.onnx&quot;, ios::binary);

modelStream.seekg(0, ios_base::end);
int bufferSize = modelStream.tellg(); //getting file size
char* modelData = new char[bufferSize];

modelStream.seekg(0, ios::beg);
modelStream.read(modelData, bufferSize);

cv::dnn::Net model = cv::dnn::readNetFromONNX(modelData, bufferSize);

delete [] modelData;
```"><pre class="notranslate"><code class="notranslate">```
ifstream modelStream("../model.onnx", ios::binary);

modelStream.seekg(0, ios_base::end);
int bufferSize = modelStream.tellg(); //getting file size
char* modelData = new char[bufferSize];

modelStream.seekg(0, ios::beg);
modelStream.read(modelData, bufferSize);

cv::dnn::Net model = cv::dnn::readNetFromONNX(modelData, bufferSize);

delete [] modelData;
```
</code></pre></div>
<p dir="auto">But if I use cv::dnn::readNetFromONNX from file, it work fine:<br>
<code class="notranslate">cv::dnn::Net model = cv::dnn::readNetFromONNX("../model.onnx");</code></p>
<h5 dir="auto">System information (version)</h5>
<ul dir="auto">
<li>OpenCV =&gt; 2</li>
<li>Operating System / Platform =&gt; Windows 10</li>
<li>Compiler =&gt; Python</li>
</ul>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">I am looking to process a video stream from webcam. I am using opencv to capture and display the video. My goal is to segment the video display window into 3 rectangles with specified width and height. When an object is detected in the rectangle then it should output left center or right. I have managed to calculated the center coordinate of the object and drawn the rectangles on the video stream display window. Based on the coordinate where it falls in one of the rectangles, then the output will be left, center or right.</p>
<p dir="auto">My question is how do i make the output when the coordinate falls within one of the box. I assumed using if center_coord in box then output but it does not work.&gt;</p>
<h5 dir="auto">Steps to reproduce</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="from darkflow.net.build import TFNet
import numpy as np
import time
from collections import namedtuple
options = {
    'model': 'cfg/yolov2.cfg',
    'load': 'bin/yolov2.weights',
    'threshold': 0.8,
    'gpu': 0.8
}


tfnet = TFNet(options)
colors = [tuple(255 * np.random.rand(3)) for _ in range(10)]

capture = cv2.VideoCapture(0, cv2.CAP_DSHOW)
capture.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
capture.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)
center_coord = namedtuple(&quot;center_coord&quot;, ['x', 'y'])

while True:
    stime = time.time()
    ret, frame = capture.read()
    box = cv2.rectangle(frame, (1, 0), (426, 720), (0, 0, 255), 2)
    box2 = cv2.rectangle(frame, (426, 0), (852, 720), (0, 0, 255), 2)
    box3 = cv2.rectangle(frame, (852, 0), (1279, 720), (0, 0, 255), 2)
    if ret:
        results = tfnet.return_predict(frame)
        for color, result in zip(colors, results):
            tl = (result['topleft']['x'], result['topleft']['y'])
            br = (result['bottomright']['x'], result['bottomright']['y'])
            center_x = ((tl[0] + br[0])/2)
            center_y = ((tl[1] + br[1])/2)
            center_box = center_coord(center_x, center_y)
            print(center_box)
            label = result['label']
            confidence = result['confidence']
            text = '{}: {:.0f}%'.format(label, confidence * 100)
            frame = cv2.rectangle(frame, tl, br, color, 5)
            frame = cv2.putText(frame, text, tl, cv2.FONT_HERSHEY_COMPLEX, 1, (0, 0, 0), 2)
        cv2.imshow('frame', frame)
        print('FPS {:.1f}'.format(1 / (time.time() - stime)))
    if cv2.waitKey(1) &amp; 0xFF == ord('q'):
        break

capture.release()
cv2.destroyAllWindows()"><pre lang="import" class="notranslate"><code class="notranslate">from darkflow.net.build import TFNet
import numpy as np
import time
from collections import namedtuple
options = {
    'model': 'cfg/yolov2.cfg',
    'load': 'bin/yolov2.weights',
    'threshold': 0.8,
    'gpu': 0.8
}


tfnet = TFNet(options)
colors = [tuple(255 * np.random.rand(3)) for _ in range(10)]

capture = cv2.VideoCapture(0, cv2.CAP_DSHOW)
capture.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
capture.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)
center_coord = namedtuple("center_coord", ['x', 'y'])

while True:
    stime = time.time()
    ret, frame = capture.read()
    box = cv2.rectangle(frame, (1, 0), (426, 720), (0, 0, 255), 2)
    box2 = cv2.rectangle(frame, (426, 0), (852, 720), (0, 0, 255), 2)
    box3 = cv2.rectangle(frame, (852, 0), (1279, 720), (0, 0, 255), 2)
    if ret:
        results = tfnet.return_predict(frame)
        for color, result in zip(colors, results):
            tl = (result['topleft']['x'], result['topleft']['y'])
            br = (result['bottomright']['x'], result['bottomright']['y'])
            center_x = ((tl[0] + br[0])/2)
            center_y = ((tl[1] + br[1])/2)
            center_box = center_coord(center_x, center_y)
            print(center_box)
            label = result['label']
            confidence = result['confidence']
            text = '{}: {:.0f}%'.format(label, confidence * 100)
            frame = cv2.rectangle(frame, tl, br, color, 5)
            frame = cv2.putText(frame, text, tl, cv2.FONT_HERSHEY_COMPLEX, 1, (0, 0, 0), 2)
        cv2.imshow('frame', frame)
        print('FPS {:.1f}'.format(1 / (time.time() - stime)))
    if cv2.waitKey(1) &amp; 0xFF == ord('q'):
        break

capture.release()
cv2.destroyAllWindows()
</code></pre></div>