Skip to content

Commit

Permalink
Merge pull request #5 from SimformSolutionsPvtLtd/feature/UNT-T21755
Browse files Browse the repository at this point in the history
feature/UNT-T21755:- Tracking Body Posture for sitting position
  • Loading branch information
bhargavbajani-simformsolutions authored Mar 14, 2024
2 parents 859d80d + 394f958 commit 06b29c7
Show file tree
Hide file tree
Showing 17 changed files with 996 additions and 262 deletions.
76 changes: 67 additions & 9 deletions iOS12_Sampler/ios12 Sampler.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions iOS12_Sampler/ios12 Sampler/AVDetailsVC.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// AVDetailsVC.swift
// ios12 Sampler
//
// Created by Dhruvil Vora on 29/02/24.
// Copyright © 2024 Testing. All rights reserved.
//

import UIKit

class AVDetailsVC: BaseCameraVC {

@IBOutlet weak var cameraView: UIView!

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
cameraView.layer.addSublayer(prevLayer!)
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
}

override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
}

@IBAction func btnLiveImageFilterClicked(_ sender: UIButton) {
let vc = self.storyboard?.instantiateViewController(withIdentifier: "ARImageDetectorVC") as? ARImageDetectorVC
self.navigationController?.pushViewController(vc!, animated: true)
}

@IBAction func btnSurfaceDetectionClicked(_ sender: UIButton) {
let vc = self.storyboard?.instantiateViewController(withIdentifier: "ARSurfaceDetectionVC") as? ARSurfaceDetectionVC
self.navigationController?.pushViewController(vc!, animated: true)
}

@IBAction func btnSittingPostureClicked(_ sender: UIButton) {
let vc = self.storyboard?.instantiateViewController(withIdentifier: "ARPostureDetection") as? ARPostureDetection
self.navigationController?.pushViewController(vc!, animated: true)
}
}
56 changes: 9 additions & 47 deletions iOS12_Sampler/ios12 Sampler/AVMainVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,25 @@
import UIKit
import AVFoundation

class AVMainVC: UIViewController, AVCaptureMetadataOutputObjectsDelegate {
class AVMainVC: BaseCameraVC {

@IBOutlet weak var cameraView: UIView!

var session: AVCaptureSession?
var device: AVCaptureDevice?
var input: AVCaptureDeviceInput?
var output: AVCaptureMetadataOutput?
var prevLayer: AVCaptureVideoPreviewLayer?

@IBOutlet weak var CameraView: UIView!

override func viewDidLoad() {
super.viewDidLoad()
createSession()
// Do any additional setup after loading the view.
cameraView.layer.addSublayer(prevLayer!)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.isNavigationBarHidden = true
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
self.navigationController?.isNavigationBarHidden = false
}

@IBAction func btnActionWorldSharing(_ sender: Any) {
let vc = self.storyboard?.instantiateViewController(withIdentifier: "ARImageLocator") as? ARImageLocator
let vc = self.storyboard?.instantiateViewController(withIdentifier: "ARImageDetectorVC") as? ARImageDetectorVC
self.navigationController?.pushViewController(vc!, animated: true)
// let vc = self.storyboard?.instantiateViewController(withIdentifier: "ARSurfaceDetectionVC") as? ARSurfaceDetectionVC
// self.navigationController?.pushViewController(vc!, animated: true)
// let vc = self.storyboard?.instantiateViewController(withIdentifier: "AVSharingWorldMapVC") as? AVSharingWorldMapVC
// self.navigationController?.pushViewController(vc!, animated: true)
}

@IBAction func btnActionScanAndDetectObjects(_ sender: UIButton) {
Expand All @@ -54,35 +42,9 @@ class AVMainVC: UIViewController, AVCaptureMetadataOutputObjectsDelegate {
let vc = self.storyboard?.instantiateViewController(withIdentifier: "AVTextureEnvironment") as? AVTextureEnvironment
self.navigationController?.pushViewController(vc!, animated: true)
}
func createSession() {
session = AVCaptureSession()
device = AVCaptureDevice.default(for: .video)

var error: NSError? = nil
do {
if device != nil {
input = try AVCaptureDeviceInput(device: device!)
}
} catch {
print(error)
}

if error == nil {
if input != nil {
session?.addInput(input!)
}
} else {
print("camera input error: \(String(describing: error))")
}

prevLayer = AVCaptureVideoPreviewLayer(session: session!)
let del = UIApplication.shared.delegate as? AppDelegate
prevLayer?.frame = (del?.window?.frame)!
prevLayer?.videoGravity = AVLayerVideoGravity.resizeAspectFill
CameraView.layer.addSublayer(prevLayer!)
DispatchQueue.global().async {
self.session?.startRunning()
}
}

@IBAction func btnMoreClicked(_ sender: UIButton) {
let vc = self.storyboard?.instantiateViewController(withIdentifier: "AVDetailsVC") as? AVDetailsVC
self.navigationController?.pushViewController(vc!, animated: true)
}
}
Loading

0 comments on commit 06b29c7

Please sign in to comment.