Skip to content

Commit c0aa3ad

Browse files
authored
Merge pull request #114 from HyperInspire/feature/add-lib-config
Feature/add lib config Former-commit-id: 471387d
2 parents a00f00b + 2b41664 commit c0aa3ad

File tree

5 files changed

+60
-32
lines changed

5 files changed

+60
-32
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ string(CONCAT INSPIRE_FACE_VERSION_PATCH_STR ${INSPIRE_FACE_VERSION_PATCH})
1919
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cpp/inspireface/information.h.in ${CMAKE_CURRENT_SOURCE_DIR}/cpp/inspireface/information.h)
2020
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cpp/inspireface/version.txt.in ${CMAKE_CURRENT_SOURCE_DIR}/cpp/inspireface/version.txt)
2121

22+
# Creates a package config file
23+
configure_file("${InspireFace_SOURCE_DIR}/cpp/inspireface/cmake/templates/InspireFaceConfig.cmake.in" "${CMAKE_BINARY_DIR}/install/InspireFaceConfig.cmake" @ONLY)
24+
2225
# Set the ISF_THIRD_PARTY_DIR variable to allow it to be set externally from the command line, or use the default path if it is not set
2326
set(ISF_THIRD_PARTY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty" CACHE PATH "Path to the third-party libraries directory")
2427

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// clang-format off
2+
# ===================================================================================
3+
# The InspireFace CMake configuration file
4+
#
5+
# ** File generated automatically, do not modify **
6+
# Usage from an external project:
7+
# In your CMakeLists.txt, add these lines:
8+
#
9+
# find_package(InspireFace REQUIRED)
10+
# include_directories(${InspireFace_INCLUDE_DIRS}) # Not needed for CMake >= 2.8.11
11+
# target_link_libraries(MY_TARGET_NAME ${InspireFace_LIBS})
12+
#
13+
#
14+
#
15+
# This file will define the following variables:
16+
# - InspireFace_LIBS : The list of all imported targets for InspireFace modules.
17+
# - InspireFace_INCLUDE_DIRS : The InspireFace include directories.
18+
#
19+
#
20+
@PACKAGE_INIT@
21+
22+
set(InspireFace_LIBS "")
23+
file(GLOB LIBS "@CMAKE_BINARY_DIR@/InspireFace/lib/*.*")
24+
25+
list(APPEND InspireFace_LIBS ${LIBS})
26+
set(InspireFace_INCLUDE_DIRS "@CMAKE_BINARY_DIR@/InspireFace/include")
27+
28+
// clang-format on

cpp/sample/CMakeLists.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ set_target_properties(MTFaceTrackSample PROPERTIES
3939
)
4040

4141
if(NOT DISABLE_GUI)
42-
# Examples of face detection and tracking
43-
add_executable(FaceTrackVideoSample cpp/sample_face_track_video.cpp)
44-
target_link_libraries(FaceTrackVideoSample InspireFace ${ext})
45-
set_target_properties(FaceTrackVideoSample PROPERTIES
46-
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/sample/"
47-
)
48-
endif()
42+
# Examples of face detection and tracking
43+
add_executable(FaceTrackVideoSample cpp/sample_face_track_video.cpp)
44+
target_link_libraries(FaceTrackVideoSample InspireFace ${ext})
45+
set_target_properties(FaceTrackVideoSample PROPERTIES
46+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/sample/"
47+
)
48+
endif ()
4949

5050

5151

@@ -265,4 +265,5 @@ install(TARGETS MTFaceTrackSample RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/sa
265265
install(TARGETS FaceRecognitionSample RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/sample)
266266
install(TARGETS FaceSearchSample RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/sample)
267267
install(TARGETS FaceComparisonSample RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/sample)
268+
install(TARGETS FaceTrackVideoSample RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/sample)
268269

cpp/sample/cpp/face_detect.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ int main() {
3131
auto img = cv::imread("/Users/tunm/Downloads/xtl.png");
3232

3333
double time;
34-
time = (double) cv::getTickCount();
34+
time = (double)cv::getTickCount();
3535
std::vector<FaceLoc> results = detect(img);
36-
time = ((double) cv::getTickCount() - time) / cv::getTickFrequency();
37-
std::cout << "use time:" << time << "\n";
36+
time = ((double)cv::getTickCount() - time) / cv::getTickFrequency();
37+
std::cout << "use time:" << time << "s\n";
3838

3939
for (size_t i = 0; i < results.size(); i++) {
4040
auto &item = results[i];

cpp/sample/cpp/sample_face_track_video.cpp

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ cv::Scalar generateColor(int id) {
2828
int maxID = 100;
2929
id = id % maxID;
3030

31-
int hue = (id * 360 / maxID) % 360;
32-
int saturation = 255;
31+
int hue = (id * 360 / maxID) % 360;
32+
int saturation = 255;
3333
int value = 200;
3434

3535
cv::Mat hsv(1, 1, CV_8UC3, cv::Scalar(hue, saturation, value));
@@ -40,7 +40,6 @@ cv::Scalar generateColor(int id) {
4040
return cv::Scalar(rgbColor[0], rgbColor[1], rgbColor[2]);
4141
}
4242

43-
4443
int main(int argc, char* argv[]) {
4544
// Check whether the number of parameters is correct
4645
if (argc != 3) {
@@ -107,11 +106,11 @@ int main(int argc, char* argv[]) {
107106
while (cap.read(frame)) {
108107
// Prepare an image parameter structure for configuration
109108
HFImageData imageParam = {0};
110-
imageParam.data = frame.data; // Data buffer
111-
imageParam.width = frame.cols; // Target view width
112-
imageParam.height = frame.rows; // Target view width
113-
imageParam.rotation = HF_CAMERA_ROTATION_0; // Data source rotate
114-
imageParam.format = HF_STREAM_BGR; // Data source format
109+
imageParam.data = frame.data; // Data buffer
110+
imageParam.width = frame.cols; // Target view width
111+
imageParam.height = frame.rows; // Target view width
112+
imageParam.rotation = HF_CAMERA_ROTATION_0; // Data source rotate
113+
imageParam.format = HF_STREAM_BGR; // Data source format
115114

116115
// Create an image data stream
117116
HFImageStream imageHandle = {0};
@@ -122,11 +121,11 @@ int main(int argc, char* argv[]) {
122121
}
123122

124123
// Execute HF_FaceContextRunFaceTrack captures face information in an image
125-
double time = (double) cv::getTickCount();
124+
double time = (double)cv::getTickCount();
126125
HFMultipleFaceData multipleFaceData = {0};
127126
ret = HFExecuteFaceTrack(session, imageHandle, &multipleFaceData);
128-
time = ((double) cv::getTickCount() - time) / cv::getTickFrequency();
129-
std::cout << "use time:" << time << "\n";
127+
time = ((double)cv::getTickCount() - time) / cv::getTickFrequency();
128+
std::cout << "use time:" << time << "s\n";
130129
if (ret != HSUCCEED) {
131130
std::cout << "Execute HFExecuteFaceTrack error: " << ret << std::endl;
132131
return ret;
@@ -143,32 +142,29 @@ int main(int argc, char* argv[]) {
143142
drawMode(draw, detMode);
144143
if (faceNum > 0) {
145144
ret = HFMultipleFacePipelineProcessOptional(session, imageHandle, &multipleFaceData, option);
146-
if (ret != HSUCCEED)
147-
{
145+
if (ret != HSUCCEED) {
148146
std::cout << "HFMultipleFacePipelineProcessOptional error: " << ret << std::endl;
149147
return ret;
150148
}
151149
HFFaceIntereactionState result;
152150
ret = HFGetFaceIntereactionStateResult(session, &result);
153-
if (ret != HSUCCEED)
154-
{
151+
if (ret != HSUCCEED) {
155152
std::cout << "HFGetFaceIntereactionStateResult error: " << ret << std::endl;
156153
return ret;
157154
}
158155
std::cout << "Left eye status: " << result.leftEyeStatusConfidence[0] << std::endl;
159156
std::cout << "Righ eye status: " << result.rightEyeStatusConfidence[0] << std::endl;
160-
161157
}
162-
158+
163159
for (int index = 0; index < faceNum; ++index) {
164160
// std::cout << "========================================" << std::endl;
165161
// std::cout << "Process face index: " << index << std::endl;
166162
// Print FaceID, In VIDEO-MODE it is fixed, but it may be lost
167163
auto trackId = multipleFaceData.trackIds[index];
168164

169165
// Use OpenCV's Rect to receive face bounding boxes
170-
auto rect = cv::Rect(multipleFaceData.rects[index].x, multipleFaceData.rects[index].y,
171-
multipleFaceData.rects[index].width, multipleFaceData.rects[index].height);
166+
auto rect = cv::Rect(multipleFaceData.rects[index].x, multipleFaceData.rects[index].y, multipleFaceData.rects[index].width,
167+
multipleFaceData.rects[index].height);
172168
cv::rectangle(draw, rect, generateColor(trackId), 3);
173169

174170
// std::cout << "FaceID: " << trackId << std::endl;
@@ -179,8 +175,8 @@ int main(int argc, char* argv[]) {
179175
// << ", Pitch: " << multipleFaceData.angles.pitch[index] << std::endl;
180176

181177
// Add TrackID to the drawing
182-
cv::putText(draw, "ID: " + std::to_string(trackId), cv::Point(rect.x, rect.y - 10),
183-
cv::FONT_HERSHEY_SIMPLEX, 0.5, generateColor(trackId), 2);
178+
cv::putText(draw, "ID: " + std::to_string(trackId), cv::Point(rect.x, rect.y - 10), cv::FONT_HERSHEY_SIMPLEX, 0.5, generateColor(trackId),
179+
2);
184180

185181
HInt32 numOfLmk;
186182
HFGetNumOfFaceDenseLandmark(&numOfLmk);
@@ -195,7 +191,7 @@ int main(int argc, char* argv[]) {
195191
cv::circle(draw, p, 0, generateColor(trackId), 2);
196192
}
197193
}
198-
194+
199195
cv::imshow("w", draw);
200196
cv::waitKey(1);
201197

0 commit comments

Comments
 (0)