Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - axelA

Pages: [1]
1
Graphics / Re: Getting camera images
« on: April 17, 2018, 10:46:53 am »
Hi !
After a lot of researsh i suceeded, heres the code :
#include "stdafx.h"
#include <SFML\Graphics.hpp>
#include <opencv2/opencv.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main()
{
        VideoCapture stream1(0);
        if (!stream1.isOpened()) {
                cout << "Camera failed to open" << endl;
        }
        sf::RenderWindow window(sf::VideoMode(1920, 1080, 32), "???");
        sf::RectangleShape rect(sf::Vector2f{1920, 1080});
        sf::Texture texture;
        sf::Event event;
        Mat sfml_rgba_frame;
        Mat cameraFrame;
        texture.loadFromFile("images/bomb.png");
        rect.setTexture(&texture, false);

        window.setFramerateLimit(30);
        while (window.isOpen()) {
                stream1.read(cameraFrame);
                cvtColor(cameraFrame, sfml_rgba_frame, CV_BGR2RGBA);
                texture.create(sfml_rgba_frame.cols, sfml_rgba_frame.rows);
                texture.update(reinterpret_cast<sf::Uint8*>(sfml_rgba_frame.ptr()));
                rect.setTexture(&texture);
                while (window.pollEvent(event)) {
                        if (event.type == sf::Event::EventType::Closed)
                                window.close();
                }
                window.clear();
                window.draw(rect);
                window.display();
        }
    return 0;
}
 
The part about converting cv::mat to sf::Texture was found here :
https://fr.sfml-dev.org/forums/index.php?topic=19621.0
Thanks for your help.

2
Graphics / Re: Getting camera images
« on: April 16, 2018, 05:33:37 pm »
Thanks for your answer, Im actualy seing OpenCV and i try to covert a Mat structure to a sfRectangleShape.
(Taking the pixel of the first one into the second one)
I hope its possible ...

3
Graphics / Re: Getting camera images
« on: April 15, 2018, 09:07:39 pm »
Well, it seems pretty hard to do...
But thanks for your help !

4
Graphics / Re: Getting camera images
« on: April 15, 2018, 06:59:26 pm »
Hi ! Thanks for your answer.
Im talking about a real life camera.
I try to do somethig like when you capture a picture, you can actualy see what you'll shot.

5
Graphics / Getting camera images
« on: April 15, 2018, 06:43:43 pm »
Hi ! Id like to know if its possible to get a camera images in real time ?
I mean, not just taking a picture and show it, but show "everything the camera sees" ?
Thanks !  :)

Pages: [1]