-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
11,441 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#Don't ignore the .gitignore (duh) | ||
!.gitignore | ||
|
||
#Ignore the makefile here since it's generated by CMake | ||
*Makefile* | ||
|
||
#Ignore executables | ||
singleCameraDemo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
cmake_minimum_required (VERSION 2.8) | ||
|
||
project(cameraDemo) | ||
|
||
# required packages and directories (OpenCV + XIMEA API) | ||
find_package(OpenCV REQUIRED) | ||
find_library(LIBM3API_LIB NAMES libm3api.so) | ||
|
||
include_directories(${OpenCV_INCLUDE_DIRS}) | ||
|
||
# problem with opencv + cuda on tegra, this setting required | ||
# must explicitly build with -D CUDA_USE_STATIC_CUDA_RUNTIME=OFF the first time | ||
message(STATUS "CUDA_USE_STATIC_CUDA_RUNTIME " ${CUDA_USE_STATIC_CUDA_RUNTIME}) | ||
|
||
# executables | ||
add_executable(singleCameraDemo | ||
singleCameraDemo.cpp | ||
xiApiPlusOcv.hpp | ||
xiApiPlusOcv.cpp) | ||
|
||
# link libraries | ||
target_link_libraries(singleCameraDemo ${OpenCV_LIBS} ${LIBM3API_LIB}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* Program opens first camera, captures 100 images, displays them, and | ||
* writes the images to jpg file in images/ directory. | ||
* | ||
* Based on the xiApiPlusOcvExample.cpp file from XIMEA. | ||
**/ | ||
#include <iostream> | ||
#include <sstream> | ||
#include "xiApiPlusOcv.hpp" | ||
#include "opencv2/highgui/highgui.hpp" | ||
|
||
int nImages = 100; | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
try | ||
{ | ||
// set up camera | ||
xiAPIplusCameraOcv cam; | ||
cam.OpenFirst(); // open the camera | ||
cam.SetExposureTime(10000); // exposure time 10 ms | ||
cam.StartAcquisition(); // start aquiring images | ||
XI_IMG_FORMAT format = cam.GetImageDataFormat(); // image format | ||
|
||
cv::Mat cap; | ||
for (int i = 0; i < nImages; i++) | ||
{ | ||
cap = cam.GetNextImageOcvMat(); // capture image | ||
|
||
// normalize image if needed (depending on format) | ||
if (format == XI_RAW16 || format == XI_MONO16) | ||
{ | ||
cv::normalize(cap, cap, 0, 65536, cv::NORM_MINMAX, | ||
-1, cv::Mat()); | ||
} | ||
|
||
// display | ||
cv::imshow("image", cap); | ||
cv::waitKey(20); | ||
|
||
// write jpeg | ||
std::ostringstream name; | ||
name << "images/"; | ||
if (i < 10) name << "0"; | ||
name << i << ".jpg"; | ||
std::cout << "Writing image " << name.str() << std::endl; | ||
cv::imwrite(name.str(), cap); | ||
} | ||
|
||
// shut down the camera | ||
cam.StopAcquisition(); | ||
cam.Close(); | ||
} | ||
catch(xiAPIplus_Exception& exp) | ||
{ | ||
std::cerr << "Error:" << std::endl; | ||
exp.PrintError(); | ||
cv::waitKey(2000); | ||
} | ||
return 0; | ||
} |
Oops, something went wrong.