added change pose landmarks functionaltiy

This commit is contained in:
Mautisim Munir 2022-10-21 10:57:12 +05:00
parent 1fb3f1dbb7
commit 003df4fe47
5 changed files with 118 additions and 10 deletions

View File

@ -15,16 +15,51 @@
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="1BO-kg-lOt">
<rect key="frame" x="0.0" y="0.0" width="414" height="125"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="dv5-h1-tjP">
<rect key="frame" x="8" y="86" width="200" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="Show Landmarks (ON)" titleAlignment="center"/>
<connections>
<action selector="showLandmarksButtonTouchWithSender:" destination="BYZ-38-t0r" eventType="touchDown" id="rE9-Y7-U5g"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="oaC-Ax-V0a">
<rect key="frame" x="216" y="86" width="190" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="MODEL (LITE)"/>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text=" Copper Labs" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="UGR-Ho-hUQ">
<rect key="frame" x="8" y="41" width="398" height="37"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleTitle0"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="tintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</view>
</subviews>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
<connections>
<outlet property="chooseModelButton" destination="oaC-Ax-V0a" id="Knp-ll-Zgu"/>
<outlet property="liveView" destination="8bC-Xf-vdC" id="COw-5j-lAL"/>
<outlet property="showLandmarksButton" destination="dv5-h1-tjP" id="xXW-UG-aSR"/>
<outlet property="titleview" destination="1BO-kg-lOt" id="uP4-0G-Gix"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="30" y="43"/>
<point key="canvasLocation" x="28.985507246376812" y="42.857142857142854"/>
</scene>
</scenes>
<resources>

View File

@ -10,8 +10,51 @@ import LinderaDetection
class ViewController: UIViewController {
@IBOutlet var liveView:UIView?;
@IBOutlet var liveView : UIView!
@IBOutlet var showLandmarksButton: UIButton!
@IBOutlet var chooseModelButton: UIButton!
@IBOutlet var titleview: UIView!
func updateLandmarksButtonText(){
if (lindera.areLandmarksShown()){
showLandmarksButton.setTitle("LANDMARKS (ON)", for: UIControl.State.normal)
}else{
showLandmarksButton.setTitle("LANDMARKS (OFF)", for: UIControl.State.normal)
}
}
func updateModelButtonText(){
}
@IBAction func showLandmarksButtonTouch(sender: UIButton){
lindera.showLandmarks(value: !lindera.areLandmarksShown());
updateLandmarksButtonText()
// let alert = UIAlertController(
// title: nil,
// message: nil,
// preferredStyle: .actionSheet
// )
//
// alert.addAction(
// .init(title: "Action 1", style: .default) { _ in
// print("Action1")
// }
// )
//
// alert.addAction(
// .init(title: "Action 2", style: .default) { _ in
// print("Action 2")
// }
// )
//
// present(alert, animated: true)
}
let lindera = Lindera()
/// A simple LinderaDelegate implementation that prints nose coordinates if detected
@ -31,9 +74,9 @@ class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
// // Do any additional setup after loading the view.
//
//
self.lindera.delegate = linderaDelegate
// add lindera camera view to our app's UIView i.e. liveView
@ -55,6 +98,10 @@ class ViewController: UIViewController {
lindera.startCamera()
self.liveView.bringSubviewToFront(titleview)
updateLandmarksButtonText()
// self.liveView.bringSubviewToFront(chooseModelButton)
}

View File

@ -45,6 +45,8 @@
- (instancetype) initWithPoseTrackingOptions: (PoseTrackingOptions*) poseTrackingOptions;
- (void)startGraph;
- (void) startWithCamera: (MPPCameraInputSource*) cameraSource;
- (void)showLandmarks: (BOOL) value;
- (BOOL) areLandmarksShown;
@end

View File

@ -144,8 +144,11 @@ static const char* kLandmarksOutputStream = "pose_landmarks";
self.graphOutputStream = "throttled_input_video";
}
[self->mediapipeGraph addFrameOutputStream:self.graphOutputStream
[self->mediapipeGraph addFrameOutputStream:"output_video"
outputPacketType:MPPPacketTypePixelBuffer];
[self->mediapipeGraph addFrameOutputStream:"throttled_input_video"
outputPacketType:MPPPacketTypePixelBuffer];
self.poseTrackingResultsListener = ^(PoseTrackingResults*){};
@ -166,7 +169,18 @@ static const char* kLandmarksOutputStream = "pose_landmarks";
return self;
}
- (void)showLandmarks: (BOOL) value{
if (value){
self->poseTrackingGraphDelegate.graphOutputStream = "output_video";
}else{
self->poseTrackingGraphDelegate.graphOutputStream = "throttled_input_video";
}
}
- (BOOL) areLandmarksShown{
return self->poseTrackingGraphDelegate.graphOutputStream == "output_video";
}
- (void)startGraph {
// Start running self.mediapipeGraph.

View File

@ -18,7 +18,17 @@ public final class Lindera{
public var cameraView: UIView {
return self.linderaExerciseSession
}
public func showLandmarks(value:Bool){
self.poseTracking.showLandmarks(value)
}
public func areLandmarksShown() -> Bool{
return self.poseTracking.areLandmarksShown()
}
// public func getModelComplexity() -> Int{
// return self.poseTracking
// }
// Initializes pipeline parameters and starts mediapipe graph
private lazy var linderaExerciseSession: UIView = {