Skip to content

Commit

Permalink
Code compiles with no errors.
Browse files Browse the repository at this point in the history
Need to test.
  • Loading branch information
Abhijit J. Theophilus committed May 23, 2017
1 parent 7c11352 commit 69601cc
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 12 deletions.
3 changes: 3 additions & 0 deletions include/enVRConsts.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef _ENVR_CONSTANTS
#define _ENVR_CONSTANTS

#include <vector>
#include <array>
#include <set>
#include <map>
Expand All @@ -11,6 +12,8 @@

namespace enVR {
const int dim = 500;
const std::vector<std::string> faces {"front", "left", "back", "right",
"top"};

/* typedefs for long types. */
typedef std::array<GLfloat, 3> points;
Expand Down
8 changes: 3 additions & 5 deletions lib/Capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,18 @@ frame_map enVR::capture_images()
{
using std::string;
frame_map frames;
std::vector<string> cams {"front", "left", "right", "back", "top"};

// For unit buffering.
std::cout.setf(std::ios::unitbuf);

cv::Mat frame;
for (uint i=0; i < cams.size(); i++) {
for (uint i=0; i < faces.size(); i++) {
std::cout << ":: Capturing image from camera " << i << " ... ";
cv::VideoCapture cap(i+1);
cap.set(CV_CAP_PROP_FRAME_WIDTH, dim);
cap.set(CV_CAP_PROP_FRAME_HEIGHT, dim);
cap >> frame;
frames[cams[i]] = frame.clone();
frames[faces[i]] = frame.clone();
std::cout << "done." << std::endl;
}

Expand Down Expand Up @@ -69,8 +68,7 @@ void enVR::save_frames(frame_map frames)
frame_map enVR::read_frames()
{
frame_map frames;
std::vector<std::string> cams {"front", "left", "right", "back", "top"};
for (auto it = cams.begin(); it != cams.end(); ++it) {
for (auto it = faces.begin(); it != faces.end(); ++it) {
cv::Mat frame = cv::imread("img/" + (*it) + ".jpg");
frames[(*it)] = frame.clone();
}
Expand Down
41 changes: 34 additions & 7 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#include "enVRConsts.hpp"
#include "Capture.hpp"
#include "Generate.hpp"
#include "Viewer.hpp"

#include <iostream>

const double lthresh = -1e100;
const double uthresh = 1e100;

int main(int argc, char* argv[])
{
using std::cout;
Expand All @@ -28,17 +32,40 @@ int main(int argc, char* argv[])
cout << "Cameras attached: 6" << endl;
cout << ":: Proceed to capture images? [y/n] ";
cin >> choice;

cout.setf(std::ios::unitbuf);

enVR::frame_map frames;
if (choice == 'y') {
cout << ":: Ignoring camera 1." << endl;
cout << ":: Beginning captures." << endl;
auto frames = enVR::capture_images();
cout << ":: Capturing images." << endl;
frames = enVR::capture_images();
cout << ":: Captures complete." << endl;
cout << ":: Saving frames to img." << endl;
cout << ":: Saving frames to img ... ";
enVR::save_frames(frames);
cout << ":: Save complete." << endl;
cout << "done." << endl;
} else {
cout << ":: Retrieving images from img." << endl;
auto frames = enVR::read_frames();
cout << ":: Frames retrieved." << endl;
cout << ":: Retrieving images from img ... ";
frames = enVR::read_frames();
cout << "done." << endl;
}

cout << ":: Extrapolating projections to 3 dimensions ... ";
enVR::point_map pmap;
for (auto it = enVR::faces.begin(); it != enVR::faces.end(); ++it) {
pmap[(*it)] = enVR::extrapolate_projection(frames[(*it)], (*it),
lthresh, uthresh);
}
cout << "done." << endl;

cout << ":: Constructing 3D image ... ";
enVR::point_set img3d = enVR::construct_3d_image(pmap);
cout << "done." << endl;

cout << ":: Initializing OpenGL viewer ... ";
enVR::init_viewer(&argc, argv);
cout << "done." << endl;

cout << ":: Reached target: Viewer." << endl;
enVR::view_3d_image(img3d);
}

0 comments on commit 69601cc

Please sign in to comment.