| 91 | int devNumber = 0) |
| 92 | #ifndef VBHMD_FAKE_IMAGES |
| 93 | : m_camera(std::move(camera)) |
| 94 | #endif |
| 95 | { |
| 96 | // Set the number of threads for OpenCV to use. |
| 97 | cv::setNumThreads(1); |
| 98 | |
| 99 | // Initialize things from parameters and from defaults. Do it here |
| 100 | // rather than in an initialization list so that we're independent of |
| 101 | // member order declaration. |
| 102 | m_channel = 0; |
| 103 | m_type = Unknown; |
| 104 | |
| 105 | /// Create the initialization options |
| 106 | OSVR_DeviceInitOptions opts = osvrDeviceCreateInitOptions(ctx); |
| 107 | |
| 108 | // Configure the tracker interface. |
| 109 | osvrDeviceTrackerConfigure(opts, &m_tracker); |
| 110 | |
| 111 | /// Come up with a device name |
| 112 | std::ostringstream os; |
| 113 | os << "TrackedCamera" << devNumber << "_" << m_channel; |
| 114 | |
| 115 | /// Create an asynchronous (threaded) device |
| 116 | m_dev.initAsync(ctx, os.str(), opts); |
| 117 | |
| 118 | /// Send JSON descriptor |
| 119 | m_dev.sendJsonDescriptor(com_osvr_VideoBasedHMDTracker_json); |
| 120 | |
| 121 | /// Register update callback |
| 122 | m_dev.registerUpdateCallback(this); |
| 123 | |
| 124 | //=============================================== |
| 125 | // Figure out what type of HMD we're using. |
| 126 | int height = 0; |
| 127 | int width = 0; |
| 128 | #ifdef VBHMD_FAKE_IMAGES |
| 129 | // Read a vector of images, which we'll loop through. |
| 130 | int imageNum = 1; |
| 131 | do { |
| 132 | std::ostringstream fileName; |
| 133 | fileName << VBHMD_FAKE_IMAGES << "/"; |
| 134 | fileName << std::setfill('0') << std::setw(4) << imageNum++; |
| 135 | fileName << ".tif"; |
| 136 | cv::Mat image; |
| 137 | #ifdef VBHMD_DEBUG |
| 138 | std::cout << "Trying to read image from " << fileName.str() |
| 139 | << std::endl; |
| 140 | #endif |
| 141 | image = cv::imread(fileName.str().c_str(), CV_LOAD_IMAGE_COLOR); |
| 142 | if (!image.data) { |
| 143 | break; |
| 144 | } |
| 145 | m_images.push_back(image); |
| 146 | } while (true); |
| 147 | m_currentImage = 0; |
| 148 | |
| 149 | if (m_images.size() == 0) { |
| 150 | std::cerr << "Could not read any images from " << VBHMD_FAKE_IMAGES |
nothing calls this directly
no test coverage detected