【问题标题】:return Caffe model results to a html web page将 Caffe 模型结果返回到 html 网页
【发布时间】:2018-07-28 02:59:05
【问题描述】:

我有一个 Caffe 模型,它检测视频中的对象并将结果显示为每个对象的边界框和类标签。我正在使用 opencv 函数“cv2.imshow()”来显示结果,但我想在 html 网页上显示这个结果。我没有使用任何框架链接 django。
我该怎么做?
这是我的代码的一部分,我想在网页上显示它的结果:

# loop over the frames from the video stream
while True:
# grab the frame from the threaded video stream and resize it
# to have a maximum width of 400 pixels
#frame = vs.read()
ret, frame = cap.read()
frame = imutils.resize(frame, width=400)

# grab the frame dimensions and convert it to a blob
(h, w) = frame.shape[:2]
blob = cv2.dnn.blobFromImage(cv2.resize(frame, (400, 300)),
    0.008, (400, 300), 128)

# pass the blob through the network and obtain the detections and predictions
net.setInput(blob)
detections = net.forward()

# loop over the detections
for i in np.arange(0, detections.shape[2]):
    # extract the confidence (i.e., probability) associated with
    # the prediction
    confidence = detections[0, 0, i, 2]

    if confidence > treshHold:
        # extract the index of the class label from the
        # `detections`, then compute the (x, y)-coordinates of
        # the bounding box for the object
        idx = int(detections[0, 0, i, 1])
        box = detections[0, 0, i, 3:7] * np.array([w, h, w, h])
        (startX, startY, endX, endY) = box.astype("int")

        # draw the prediction on the frame
        label = "{}: {:.2f}%".format(CLASSES[idx],
            confidence * 100)
        cv2.rectangle(frame, (startX, startY), (endX, endY),
            COLORS[idx], 2)
        y = startY - 15 if startY - 15 > 15 else startY + 15
        cv2.putText(frame, label, (startX, y),
            cv2.FONT_HERSHEY_SIMPLEX, 0.5, COLORS[idx], 2)

# show the output frame
cv2.imshow("Frame", frame)
key = cv2.waitKey(1) & 0xFF

# if the `q` key was pressed, break from the loop
if key == ord("q"):
    break

【问题讨论】:

    标签: html opencv python-3.5


    【解决方案1】:

    编写html页面,插入必要的链接,将结果写入文件,你就完成了。 在这里查看例如:link

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-08-15
      • 1970-01-01
      • 1970-01-01
      • 2020-02-12
      • 1970-01-01
      • 2013-03-06
      • 2014-05-06
      • 1970-01-01
      相关资源
      最近更新 更多