Outils pour utilisateurs

Outils du site


diy:projets:chromakey

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
diy:projets:chromakey [2018/06/25 09:05] – [Sources du projet] sduranddiy:projets:chromakey [2018/07/02 09:35] (Version actuelle) – [Sources du projet] sdurand
Ligne 447: Ligne 447:
 === "Récepteur" === === "Récepteur" ===
  
 +<code C++>
 +#include <iostream>
 +#include <chrono>
 +#include <opencv2/opencv.hpp>
 +
 +// WIDTH, HEIGHT and NUMBER_OF_FRAMES should always be set to the same value as in the transmitter
 +#define WIDTH 1280
 +#define HEIGHT 720
 +// Maximum size of the received frame
 +// In theory, if jpeg doesn't compress the image at all, it could be larger than that because of the format overhead
 +// I'm not sure it can ever happen, so, as this program should not be used for critical stuff (it really should not), I'm just gonna assume it won't happen
 +#define FRAME_SIZE WIDTH*HEIGHT*3 
 +#define NUMBER_OF_FRAMES 150
 +
 +#define ALL_GOOD 0
 +
 +
 +
 +int main(int argc, char **argv) {
 + // Actual size of the received frame
 + unsigned int size; 
 + uchar buffer[FRAME_SIZE];
 + cv::Mat frame;
 +
 + for(int frame_count = 0; frame_count < NUMBER_OF_FRAMES; frame_count++) {
 + // Reading the encoded image from stdin
 + // unsigned int and uchar size are the same on ARM and 64 bits regular computer
 + fread(&size, sizeof(unsigned int), 1, stdin);
 + fread(buffer, sizeof(uchar), size, stdin);
 +
 + std::vector<uchar> data(buffer, buffer+size);
 +
 + // Decoding the received frame
 + frame = cv::imdecode(cv::Mat(data), cv::IMREAD_UNCHANGED);
 +
 + // Displaying the received frame
 + cv::imshow("frame", frame);
 +
 + // This wait is mandatory for the image to actually display
 + cv::waitKey(1);
 + }
 +
 + return ALL_GOOD;
 +}
 +</code>
  
 ---- ----
-//Auteur: Sylvain D//+//Auteur: S. Durand//
diy/projets/chromakey.1529917550.txt.gz · Dernière modification : 2018/06/25 09:05 de sdurand