首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何将图片保存到sqlite数据库?

如何将图片保存到sqlite数据库?
EN

Stack Overflow用户
提问于 2020-08-11 02:53:45
回答 1查看 93关注 0票数 0

我已经创建了一个php文件index.php,它用于面罩检测程序,其中一旦用户按下按钮,它将保存到本地到桌面。我的问题是如何将其保存到数据库中并在index.php中通知

我的index.php文件

代码语言:javascript
运行
复制
<!DOCTYPE html>
<h1>COVID-19 Mask Detection<h1>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.9.0/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.9.0/addons/p5.dom.min.js"></script>
<script src="https://unpkg.com/ml5@latest/dist/ml5.min.js"></script>
<button type="button" onclick="save()">Save Now</button>
<script type="text/javascript">
  // Classifier Variable
  let classifier;
  // Model URL
  let imageModelURL = 'https://teachablemachine.withgoogle.com/models/QLX6cenjl/';
  
  // Video
  let video;
  let flippedVideo;
  // To store the classification
  let label = "";

  // Load the model first
  function preload() {
    classifier = ml5.imageClassifier(imageModelURL + 'model.json');
  }

  function setup() {
    createCanvas(1920, 750);
    // Create the video
    video = createCapture(VIDEO);
    video.size(1920, 750);
    video.hide();

    flippedVideo = ml5.flipImage(video);
    // Start classifying
    classifyVideo();
  }
  
  function save() {
      <?php

$database = SQLITE3_OPEN_READWRITE('data.db');  

  
    
    ?>

  }
  

  function draw() {
    background(0);
    // Draw the video
    image(flippedVideo, 0, 0);

    // Draw the label
    fill(255);
    textSize(16);
    textAlign(CENTER);
    text(label, width / 2, height - 4);
  }

  // Get a prediction for the current video frame
  function classifyVideo() {
    flippedVideo = ml5.flipImage(video);
    classifier.classify(flippedVideo, gotResult);
    flippedVideo.remove();

  }

  // When we get a result
  function gotResult(error, results) {
    // If there is an error
    if (error) {
      console.error(error);
      return;
    }
    // The results are in an array ordered by confidence.
    // console.log(results[0]);
    label = results[0].label;
    // Classifiy again!
    classifyVideo();
  }
</script>

function save()是用于保存图像的回调函数。但现在我被困在如何将图像保存到sqlite数据库中。

错误日志:

代码语言:javascript
运行
复制
Fatal error: Uncaught Error: Call to undefined function SQLITE3_OPEN_READWRITE() in C:\wamp64\www\Tester\index.php on line 80

Error: Call to undefined function SQLITE3_OPEN_READWRITE() in C:\wamp64\www\Tester\index.php on line 80
EN

Stack Overflow用户

发布于 2020-08-11 03:46:03

你不应该将图像直接存储在数据库中。我假设您想将其保存为blob。更好的方法是为图像创建一个单独的文件夹,并将这些图像的路径存储在数据库中。

票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63346330

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档