Skip to content

Commit

Permalink
update ExtractRawData example on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkWin committed Oct 9, 2019
1 parent b2bc4ba commit e202822
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build/
29 changes: 26 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,30 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
)
set(PointCloud ./libs/macos/lib)
message("use PointCloud SDK ./libs/macos/lib")
ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "Windows")

SET(WINDOWS 1)
set(PointCloud ./libs/windows/lib)

add_definitions(/fp:fast /W0 /bigobj /arch:AVX2 )
ADD_DEFINITIONS(-DWINDOWS -DEnableCyAPI /wd4251 -DDLIB_HAVE_AVX2)
set(COMMON_INCLUDE
${COMMON_INCLUDE}
./libs/windows/include/pointcloud-1.0.0/
${CMAKE_SOURCE_DIR}/3party/windows/libusb1.0.0/include
Util/
)

if(NOT MSVC_VERSION GREATER 1800)
SET(COMMON_LIBS setupapi strmiids strmbase Cfgmgr32 Version)
else()
SET(COMMON_LIBS setupapi strmiids strmbase Cfgmgr32 Version legacy_stdio_definitions)
endif()





else()
message(FATAL_ERROR "This project not support platform:${CMAKE_SYSTEM_NAME}")
endif()
Expand All @@ -74,6 +97,6 @@ set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE)
set(CPACK_PACKAGE_VENDOR "pointcloud.ai")
set(CPACK_SOURCE_GENERATOR "Developer")

#add_subdirectory(examples/DepthGesture)
add_subdirectory(examples/DepthMeasure)
add_subdirectory(examples/DepthAscii)
add_subdirectory(examples/ExtractRawData)
#add_subdirectory(examples/DepthMeasure)
#add_subdirectory(examples/DepthAscii)
6 changes: 3 additions & 3 deletions examples/ExtractRawData/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ project(ExtractRawData)

set(CMAKE_CXX_STANDARD 11)

LINK_DIRECTORIES(./opencv/lib)
#//LINK_DIRECTORIES(opencv/lib)

find_library(LIBUSB_LIBS
NAMES usb
PATHS /usr/local/lib
)
INCLUDE_DIRECTORIES(opencv/include)
#//INCLUDE_DIRECTORIES(opencv/include)

add_executable(ExtractRawData ExtractRawData.cpp)
target_link_libraries(ExtractRawData pointcloud opencv_imgcodecs opencv_core)
target_link_libraries(ExtractRawData pointcloud )

IF(LINUX)
set(CPACK_COMPONENTS_ALL ExtractRawData)
Expand Down
34 changes: 20 additions & 14 deletions examples/ExtractRawData/ExtractRawData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ using namespace PointCloud;
#include <stdio.h>
#include <string.h>
#include "CameraSystem.h"
#if defined(LINUX)
#include <sys/wait.h>
#endif
#include <iostream>
#include <fstream>
#include <complex>

#include "opencv2/opencv.hpp"
#include "opencv/cv.h"
//#include "opencv2/opencv.hpp"
//#include "opencv/cv.h"

using namespace std;

Expand Down Expand Up @@ -64,12 +66,12 @@ void rawABdataCallback(DepthCamera &dc, const Frame &frame, DepthCamera::FrameTy
Complex c;
float factor = 255.0/1024;
// std::cout << " factor : " << factor << std::endl;
cv::Mat tof_amplitude=cv::Mat::zeros(height,width,CV_8UC1);
unsigned char *pamp = tof_amplitude.data;
// cv::Mat tof_amplitude=cv::Mat::zeros(height,width,CV_8UC1);
//unsigned char *pamp = tof_amplitude.data;

char filename[50] = { 0 };
sprintf(filename, "RawDataAMP_%llu.bmp", rawDataFrame->timestamp);

/*
for(int j = 0;j< width*height;j+=2)
{
// calculate two pixel at the same time
Expand Down Expand Up @@ -120,7 +122,10 @@ void rawABdataCallback(DepthCamera &dc, const Frame &frame, DepthCamera::FrameTy
index += 3;
}
cv::imwrite(filename,tof_amplitude);
*/
std::cout << "Write amplitude to file with name " << filename << std::endl;


}

Expand All @@ -130,51 +135,52 @@ int main(int argc,char *argv[]) {

_sineTable.resize(phase_count);
_cosineTable.resize(phase_count);
//logger.setDefaultLogLevel(LOG_DEBUG);

for(auto i = 0; i < phase_count; i++)
{
_sineTable[i] = sin(2*M_PI/phase_count*i);
_cosineTable[i] = cos(2*M_PI/phase_count*i);
logger(LOG_DEBUG) << "table @" << i << " = " << _sineTable[i] << ", " << _cosineTable[i] << std::endl;
std::cout << "table @" << i << " = " << _sineTable[i] << ", " << _cosineTable[i] << std::endl;
}

logger.setDefaultLogLevel(LOG_DEBUG);

CameraSystem sys;

DevicePtr device;
const Vector<DevicePtr> &devices = sys.scan();
bool found = false;
for (auto &d: devices){
logger(LOG_INFO) << " ||| Detected devices: " << d->id() << std::endl;
std::cout << " ||| Detected devices: " << d->id() << std::endl;
device = d;
found = true;
}
if (!found){
logger(LOG_INFO) << " ||| No device found " << std::endl;
std::cout << " ||| No device found " << std::endl;
return 0;
}
DepthCameraPtr depthCamera;
depthCamera = sys.connect(device);
if (!depthCamera) {
logger(LOG_ERROR) << " ||| Could not load depth camera for device "<< device->id() << std::endl;
std::cout << " ||| Could not load depth camera for device "<< device->id() << std::endl;
return 1;
}

FrameRate r;
if(depthCamera->getFrameRate(r))
logger(LOG_INFO) << " ||| Capturing at a frame rate of " << r.getFrameRate() << " fps" << std::endl;
std::cout << " ||| Capturing at a frame rate of " << r.getFrameRate() << " fps" << std::endl;
r.numerator = 3;
depthCamera->setFrameRate(r);
if(depthCamera->getFrameRate(r))
logger(LOG_INFO) << " ||| Capturing at a frame rate of " << r.getFrameRate() << " fps" << std::endl;
std::cout << " ||| Capturing at a frame rate of " << r.getFrameRate() << " fps" << std::endl;

FrameSize s;
if(depthCamera->getFrameSize(s))
logger(LOG_INFO) << " ||| Frame size : " << s.width << " * "<< s.height << std::endl;
std::cout << " ||| Frame size : " << s.width << " * "<< s.height << std::endl;
int centerPointIndex = (s.height/2 ) * s.width + s.width/2;

if (!depthCamera->isInitialized()) {
logger(LOG_ERROR) << " ||| Depth camera not initialized for device "<< device->id() << std::endl;
std::cout << " ||| Depth camera not initialized for device "<< device->id() << std::endl;
return 1;
}
std::cout << " ||| Successfully loaded depth camera for device " << std::endl;
Expand Down

0 comments on commit e202822

Please sign in to comment.