core calculator error fixes

This commit is contained in:
Mautisim Munir 2022-11-01 22:00:19 +05:00
parent 42a36dafc3
commit 8c95126a67
13 changed files with 113 additions and 20 deletions

View File

@ -528,11 +528,11 @@ load("@build_bazel_rules_android//android:rules.bzl", "android_ndk_repository",
android_sdk_repository( android_sdk_repository(
name = "androidsdk", name = "androidsdk",
build_tools_version = "30.0.3", build_tools_version = "30.0.3",
# path = "/Users/tj/Library/Android/sdk", # Path to Android SDK, optional if $ANDROID_HOME is set path = "/Users/tj/Library/Android/sdk", # Path to Android SDK, optional if $ANDROID_HOME is set
) )
android_ndk_repository( android_ndk_repository(
name = "androidndk", # Required. Name *must* be "androidndk". name = "androidndk", # Required. Name *must* be "androidndk".
api_level = 21, api_level = 21,
# path = "/Users/tj/Library/Android/sdk/ndk/21.4.7075529", # Optional. Can be omitted if `ANDROID_NDK_HOME` environment variable is set. path = "/Users/tj/Library/Android/sdk/ndk/21.4.7075529", # Optional. Can be omitted if `ANDROID_NDK_HOME` environment variable is set.
) )

View File

@ -728,7 +728,7 @@ cc_library(
cc_library( cc_library(
name = "flow_limiter_calculator", name = "flow_limiter_calculator",
srcs = ["flow_limiter_calculator.cc"], srcs = ["flow_limiter_calculator.h"],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [ deps = [
":flow_limiter_calculator_cc_proto", ":flow_limiter_calculator_cc_proto",
@ -1217,7 +1217,7 @@ cc_test(
cc_library( cc_library(
name = "constant_side_packet_calculator", name = "constant_side_packet_calculator",
srcs = ["constant_side_packet_calculator.cc"], srcs = ["constant_side_packet_calculator.h"],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [ deps = [
":constant_side_packet_calculator_cc_proto", ":constant_side_packet_calculator_cc_proto",

View File

@ -5,8 +5,8 @@
// Created by Mautisim Munir on 17/10/2022. // Created by Mautisim Munir on 17/10/2022.
// //
import UIKit import UIKit
import MPPoseTracking
import LinderaDetection import LinderaDetection
//import LinderaDetection
class ViewController: UIViewController { class ViewController: UIViewController {

View File

@ -23,6 +23,9 @@
#define REGISTER_CALCULATOR(name) \ #define REGISTER_CALCULATOR(name) \
REGISTER_FACTORY_FUNCTION_QUALIFIED( \ REGISTER_FACTORY_FUNCTION_QUALIFIED( \
mediapipe::CalculatorBaseRegistry, calculator_registration, name, \ mediapipe::CalculatorBaseRegistry, calculator_registration, name, \
absl::make_unique<mediapipe::internal::CalculatorBaseFactoryFor<name>>) absl::make_unique<mediapipe::internal::CalculatorBaseFactoryFor<name>>); \
void register_##name(){typeid(name);};
#endif // MEDIAPIPE_FRAMEWORK_CALCULATOR_REGISTRY_H_ #endif // MEDIAPIPE_FRAMEWORK_CALCULATOR_REGISTRY_H_

View File

@ -286,3 +286,14 @@ exports_files(
"//mediapipe:__subpackages__", "//mediapipe:__subpackages__",
], ],
) )
exports_files(
[
"MPPCameraInputSource.h",
"MPPLayerRenderer.h",
"MPPPlayerInputSource.h",
"MPPInputSource.h",
"MPPGLViewRenderer.h",
],
visibility = ["//visibility:public"],
)

View File

@ -1,31 +1,91 @@
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application", "ios_framework", "ios_static_framework", "ios_unit_test") load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application", "ios_framework", "ios_static_framework", "ios_unit_test")
MPP_HEADERS = [
"PoseTracking.h",
"PoseTrackingOptions.h",
"PoseTrackingResults.h",
]
MP_IOS_HEADERS_NAMES = [
"MPPCameraInputSource.h",
"MPPLayerRenderer.h",
"MPPPlayerInputSource.h",
"MPPInputSource.h",
"MPPGLViewRenderer.h",
]
MP_IOS_HEADERS = ["//mediapipe/objc:" + header for header in MP_IOS_HEADERS_NAMES]
#[genrule(
# name = "gen_" + header_name,
# srcs = [header_rule],
# outs = [header_name],
# cmd = """
# OUTPUT_DIR=mediapipe/objc/solutions/posetracking_gpu
# mkdir -p $$OUTPUT_DIR
# OUTPUT_PATH=$$OUTPUT_DIR/{}
# cp $(location {}) $$OUTPUT_PATH
# sed -i -e "s#mediapipe/objc/##g" $$OUTPUT_PATH
# cp $$OUTPUT_PATH $@
# """.format(header_name, header_rule),
# local = False,
#) for (header_name, header_rule) in zip(MP_IOS_HEADERS_NAMES, MP_IOS_HEADERS)]
#
#MP_GEN_IOS_HEADERS = ["gen_" + header for header in MP_IOS_HEADERS_NAMES]
#
#filegroup(
# name = "gen_mp_ios_headers",
# srcs = MP_GEN_IOS_HEADERS,
#)
#-c opt --config=ios_fat --cxxopt=--std=c++17 --copt=-fembed-bitcode --linkopt="-s"
MP_GEN_IOS_HEADERS = MP_IOS_HEADERS
ios_static_framework( ios_static_framework(
name = "MPPoseTracking", name = "MPPoseTracking",
# hdrs = EDGE_ENGINE_HDRS, hdrs = MPP_HEADERS + MP_GEN_IOS_HEADERS,
bundle_name = "MPPoseTracking", bundle_name = "MPPoseTracking",
linkopts = [
# "--no-whole-archive",
# "-all_load",
# "-Wl",
],
minimum_os_version = "12.0", minimum_os_version = "12.0",
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [ deps = [
":posetracking_gpu_solution", "//mediapipe/objc/solutions/posetracking_gpu:posetracking_gpu_solution",
"//mediapipe/calculators/core:flow_limiter_calculator",
# "//third_party:opencv", # "//third_party:opencv",
# "@ios_opencv//:OpencvFramework", # "@ios_opencv//:OpencvFramework",
], ],
) )
# Custom Bazel Rule that patches headers of framework to flatten header imports
genrule(
name = "MPPoseTrackingHeaderPatched",
srcs = [":MPPoseTracking"],
outs = ["MPPoseTrackingHeaderPatched.zip"],
cmd = """
unzip $(location MPPoseTracking)
sed -i -e "s#mediapipe/objc/##g" $$(find MPPoseTracking.framework -name "*.h")
rm -f MPPoseTracking.framework/Headers/*.h-e
zip -r MPPoseTrackingHeaderPatched.zip MPPoseTracking.framework
cp MPPoseTrackingHeaderPatched.zip $@
""",
visibility = ["//visibility:public"],
)
objc_library( objc_library(
name = "posetracking_gpu_solution", name = "posetracking_gpu_solution",
srcs = glob([ srcs = glob([
"*.h", "*.h",
"*.mm", "*.mm",
]), ]),
hdrs = [ hdrs = MPP_HEADERS + MP_GEN_IOS_HEADERS,
"PoseTracking.h",
"PoseTrackingOptions.h",
"PoseTrackingResults.h",
],
copts = [ copts = [
"-Wno-shorten-64-to-32", "-Wno-shorten-64-to-32",
# "-all_load",
], ],
data = [ data = [
"//mediapipe/graphs/pose_tracking:pose_tracking_gpu.binarypb", "//mediapipe/graphs/pose_tracking:pose_tracking_gpu.binarypb",
@ -34,6 +94,11 @@ objc_library(
"//mediapipe/modules/pose_landmark:pose_landmark_heavy.tflite", "//mediapipe/modules/pose_landmark:pose_landmark_heavy.tflite",
"//mediapipe/modules/pose_landmark:pose_landmark_lite.tflite", "//mediapipe/modules/pose_landmark:pose_landmark_lite.tflite",
], ],
linkopts = [
# "--no-whole-archive",
# "-all_load",
# "-Wl",
],
module_name = "MPPoseTracking", module_name = "MPPoseTracking",
sdk_frameworks = ["Accelerate"], sdk_frameworks = ["Accelerate"],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
@ -41,6 +106,7 @@ objc_library(
"//mediapipe/objc:mediapipe_framework_ios", "//mediapipe/objc:mediapipe_framework_ios",
"//mediapipe/objc:mediapipe_input_sources_ios", "//mediapipe/objc:mediapipe_input_sources_ios",
"//mediapipe/objc:mediapipe_layer_renderer", "//mediapipe/objc:mediapipe_layer_renderer",
"//mediapipe/calculators/core:flow_limiter_calculator",
] + select({ ] + select({
"//mediapipe:ios_i386": [], "//mediapipe:ios_i386": [],
"//mediapipe:ios_x86_64": [], "//mediapipe:ios_x86_64": [],
@ -51,3 +117,8 @@ objc_library(
}), }),
alwayslink = True, alwayslink = True,
) )
exports_files(
MPP_HEADERS,
visibility = ["//visibility:public"],
)

View File

@ -10,6 +10,7 @@
#import "mediapipe/objc/MPPPlayerInputSource.h" #import "mediapipe/objc/MPPPlayerInputSource.h"
#import "PoseTrackingOptions.h" #import "PoseTrackingOptions.h"
#import "PoseTrackingResults.h" #import "PoseTrackingResults.h"
@interface PoseTracking : NSObject<MPPInputSourceDelegate> @interface PoseTracking : NSObject<MPPInputSourceDelegate>
// The MediaPipe graph currently in use. Initialized in viewDidLoad, started in // The MediaPipe graph currently in use. Initialized in viewDidLoad, started in

View File

@ -3,6 +3,10 @@
#import "mediapipe/objc/MPPGraph.h" #import "mediapipe/objc/MPPGraph.h"
#import "mediapipe/objc/MPPTimestampConverter.h" #import "mediapipe/objc/MPPTimestampConverter.h"
#include "mediapipe/framework/packet.h" #include "mediapipe/framework/packet.h"
#include "mediapipe/calculators/core/flow_limiter_calculator.h"
#include "mediapipe/calculators/core/constant_side_packet_calculator.h"
static const char* kVideoQueueLabel = "com.google.mediapipe.example.videoQueue"; static const char* kVideoQueueLabel = "com.google.mediapipe.example.videoQueue";
static const char* kLandmarksOutputStream = "pose_landmarks"; static const char* kLandmarksOutputStream = "pose_landmarks";
@ -127,6 +131,9 @@ static const char* kLandmarksOutputStream = "pose_landmarks";
} }
- (instancetype) initWithPoseTrackingOptions: (PoseTrackingOptions*) poseTrackingOptions{ - (instancetype) initWithPoseTrackingOptions: (PoseTrackingOptions*) poseTrackingOptions{
typeid(::mediapipe::FlowLimiterCalculator);
typeid(::mediapipe::ConstantSidePacketCalculator);
self.renderer = [[MPPLayerRenderer alloc] init]; self.renderer = [[MPPLayerRenderer alloc] init];
self.renderer.frameScaleMode = MPPFrameScaleModeFillAndCrop; self.renderer.frameScaleMode = MPPFrameScaleModeFillAndCrop;

View File

@ -18,16 +18,16 @@ POSETRACKING_DEPS = [
genrule( genrule(
name = "podgen", name = "podgen",
srcs = [ srcs = [
"lindera-framework", "//mediapipe/objc/solutions/posetracking_gpu:MPPoseTrackingHeaderPatched",
"LinderaDetection.podspec", "LinderaDetection.podspec",
], ] + glob(["*.swift"]),
outs = ["LinderaDetection.zip"], outs = ["LinderaDetection.zip"],
cmd = """ cmd = """
mkdir mediapipe/swift/solutions/lindera/frameworks mkdir mediapipe/swift/solutions/lindera/frameworks
unzip $(location lindera-framework) -d mediapipe/swift/solutions/lindera/frameworks unzip $(location //mediapipe/objc/solutions/posetracking_gpu:MPPoseTrackingHeaderPatched) -d mediapipe/swift/solutions/lindera/frameworks
cd mediapipe/swift/solutions/lindera/ cd mediapipe/swift/solutions/lindera/
zip -r LinderaDetection.zip frameworks LinderaDetection.podspec zip -r LinderaDetection.zip frameworks LinderaDetection.podspec *.swift
cd ../../../../ cd ../../../../
cp mediapipe/swift/solutions/lindera/LinderaDetection.zip $@ cp mediapipe/swift/solutions/lindera/LinderaDetection.zip $@
""", """,

View File

@ -86,7 +86,7 @@ Pod::Spec.new do |spec|
# Not including the public_header_files will make all headers public. # Not including the public_header_files will make all headers public.
# #
# spec.source_files = "" spec.source_files = "*.swift"
# spec.exclude_files = "Classes/Exclude" # spec.exclude_files = "Classes/Exclude"
# spec.public_header_files = "" # spec.public_header_files = ""
@ -101,7 +101,7 @@ Pod::Spec.new do |spec|
# #
# spec.resource = "icon.png" # spec.resource = "icon.png"
# spec.resources = "Resources/*.png" spec.resources = ["frameworks/*/*.tflite","frameworks/*/*.binarypb"]
# spec.preserve_paths = "FilesToSave", "MoreFilesToSave" # spec.preserve_paths = "FilesToSave", "MoreFilesToSave"