Ask Your Question

Revision history [back]

Fatest program whitch gets rgb values for NN

Hi,

what is the best way to get any pixel rgb values in an image ? By best way i ear the way whitch takes least computing power.

#include <opencv2/videoio.hpp>

include <opencv2 highgui.hpp="">

include <iostream>

using namespace cv; using namespace std;

unsigned char *p;

int main() { Mat image;

VideoCapture camera;

camera.open(0);

camera >> image;

imwrite("/home/silvano/image.jpg", image);

camera.release();

p = image.ptr(250,250);

cout << " red " << p[0] << " green " << p[1] << " blue " << p[2];

return 0;

}

This code opens camera, records an image and places it in /home/silvano, then displays in terminal rgb values in a unsigned char format. About the program, is it the fatest and would you advise me to use it for neural network processing ?