# Opencv.js how to get a frame from cv.read and past to a API od face recognition?

**URL:** https://forum.opencv.org/t/opencv-js-how-to-get-a-frame-from-cv-read-and-past-to-a-api-od-face-recognition/10295
**Category:** Uncategorized
**Tags:** opencvjs
**Created:** [September 23, 2022, 4:00pm UTC](https://forum.opencv.org/t/opencv-js-how-to-get-a-frame-from-cv-read-and-past-to-a-api-od-face-recognition/10295 "2022-09-23T16:00:48Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Mariano\_Moscatelli](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/mariano_moscatelli/32/6123_2.png) [@Mariano\_Moscatelli](https://forum.opencv.org/u/Mariano_Moscatelli)
#### Post date: [September 23, 2022, 4:00pm UTC](https://forum.opencv.org/t/opencv-js-how-to-get-a-frame-from-cv-read-and-past-to-a-api-od-face-recognition/10295/1 "2022-09-23T16:00:48Z")

</div>

Hello,

I have a python code to face recognition working fine. but now I am trying to implement a webpage that will capture a frame using opencv.js and them execute a ajax POST passing this frame capture to my recognition API.

My question is: are there any way in javascript to create a var frame variavel as Frame = cv.read() por example and this Frame passing to my API?

I tried to get da Frame variable value and when I am debugging daesnt happend.

this is my code example

let video = document.getElementById(‘videoInput’);  
let src = new cv.Mat(video.height, video.width, cv.CV\_8UC4);  
let dst = new cv.Mat(video.height, video.width, cv.CV\_8UC1);  
let cap = new cv.VideoCapture(video);

```
const FPS = 30;
function processVideo() {
    try {
        if (!streaming) {
            // clean and stop.
            src.delete();
            dst.delete();
            return;
        }
        let begin = Date.now();
        // start processing.
        Frame = cap.read(src); #Here I tried to get de value but cap.read doesn not set the Frame variable  
        let frameleitura = Frame 
        let delay = 1000/FPS - (Date.now() - begin);
        setTimeout(processVideo, delay);
    } catch (err) {
        utils.printError(err);
    }
};

// schedule the first one.
setTimeout(processVideo, 0);

```

---

<div class="post-metadata">

### Author: ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)
#### Post date: [September 24, 2022, 10:36am UTC](https://forum.opencv.org/t/opencv-js-how-to-get-a-frame-from-cv-read-and-past-to-a-api-od-face-recognition/10295/2 "2022-09-24T10:36:43Z")

</div>

please try to [follow the opencv.js tutorials](https://docs.opencv.org/4.x/dd/d00/tutorial_js_video_display.html) as close as possible

(e.g. `cap.read(src)` reads an image into `src`, and returns a bool from grab)
