0% found this document useful (0 votes)
26 views2 pages

Camera Code

The document contains code for connecting a Raspberry Pi camera to OpenCV and retrieving frames from the camera. It sets properties like frame width, height, brightness and contrast on the camera. It then grabs frames from the camera and calculates the frames per second in a loop, displaying the frames.

Uploaded by

kiran
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

Camera Code

The document contains code for connecting a Raspberry Pi camera to OpenCV and retrieving frames from the camera. It sets properties like frame width, height, brightness and contrast on the camera. It then grabs frames from the camera and calculates the frames per second in a loop, displaying the frames.

Uploaded by

kiran
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <opencv2/opencv.

hpp>
#include <raspicam_cv.h>
#include <iostream>
#include <chrono>
#include <ctime>

using namespace std;


using namespace cv;
using namespace raspicam;

Mat frame;

void Setup ( int argc,char **argv, RaspiCam_Cv &Camera )


{
Camera.set ( CAP_PROP_FRAME_WIDTH, ( "-w",argc,argv,400 ) );
Camera.set ( CAP_PROP_FRAME_HEIGHT, ( "-h",argc,argv,240 ) );
Camera.set ( CAP_PROP_BRIGHTNESS, ( "-br",argc,argv,50 ) );
Camera.set ( CAP_PROP_CONTRAST ,( "-co",argc,argv,50 ) );
Camera.set ( CAP_PROP_SATURATION, ( "-sa",argc,argv,50 ) );
Camera.set ( CAP_PROP_GAIN, ( "-g",argc,argv ,50 ) );
Camera.set ( CAP_PROP_FPS, ( "-fps",argc,argv,100));

int main(int argc,char **argv)


{

RaspiCam_Cv Camera;
Setup(argc, argv, Camera);
cout<<"Connecting to camera"<<endl;
if (!Camera.open())
{

cout<<"Failed to Connect"<<endl;
}

cout<<"Camera Id = "<<Camera.getId()<<endl;

while(1)
{
auto start = std::chrono::system_clock::now();
Camera.grab();
Camera.retrieve( frame);
auto end = std::chrono::system_clock::now();

std::chrono::duration<double> elapsed_seconds = end-start;

float t = elapsed_seconds.count();
int FPS = 1/t;
cout<<"FPS = "<<FPS<<endl;
imshow("orignal", frame);
waitKey(1);

return 0;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy