Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Human #22

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 6 additions & 22 deletions YOLO.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@
636EFCAF21E62DD300DE43BC /* VideoCapture.swift in Sources */ = {isa = PBXBuildFile; fileRef = 636EFCA221E62DD300DE43BC /* VideoCapture.swift */; };
636EFCB321E62DD300DE43BC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 636EFCA721E62DD300DE43BC /* AppDelegate.swift */; };
636EFCB921E62E3900DE43BC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 636EFCB821E62E3900DE43BC /* Assets.xcassets */; };
6381D2182B7817C200ABA4E8 /* yolov8l.mlpackage in Sources */ = {isa = PBXBuildFile; fileRef = 6381D2132B7817C200ABA4E8 /* yolov8l.mlpackage */; };
6381D2192B7817C200ABA4E8 /* yolov8x.mlpackage in Sources */ = {isa = PBXBuildFile; fileRef = 6381D2142B7817C200ABA4E8 /* yolov8x.mlpackage */; };
6381D21A2B7817C200ABA4E8 /* yolov8s.mlpackage in Sources */ = {isa = PBXBuildFile; fileRef = 6381D2152B7817C200ABA4E8 /* yolov8s.mlpackage */; };
6381D21B2B7817C200ABA4E8 /* yolov8m.mlpackage in Sources */ = {isa = PBXBuildFile; fileRef = 6381D2162B7817C200ABA4E8 /* yolov8m.mlpackage */; };
6381D21C2B7817C200ABA4E8 /* yolov8n.mlpackage in Sources */ = {isa = PBXBuildFile; fileRef = 6381D2172B7817C200ABA4E8 /* yolov8n.mlpackage */; };
63CF371F2514455300E2DEA1 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6323C44D22186177008AE681 /* LaunchScreen.storyboard */; };
63CF37202514455300E2DEA1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6323C44F22186177008AE681 /* Main.storyboard */; };
63CF37212514455300E2DEA1 /* ultralytics_yolo_logotype.png in Resources */ = {isa = PBXBuildFile; fileRef = 6323C45122186177008AE681 /* ultralytics_yolo_logotype.png */; };
730E72CD2BFC43BF000E1F45 /* PostProcessing.swift in Sources */ = {isa = PBXBuildFile; fileRef = 730E72CC2BFC43BF000E1F45 /* PostProcessing.swift */; };
8EDAA33950796844333D60A7 /* BoundingBoxView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8EDAA633C1F2B50286D16008 /* BoundingBoxView.swift */; };
/* End PBXBuildFile section */

Expand All @@ -35,12 +31,8 @@
636EFCA221E62DD300DE43BC /* VideoCapture.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VideoCapture.swift; sourceTree = "<group>"; };
636EFCA721E62DD300DE43BC /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
636EFCB821E62E3900DE43BC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
6381D2132B7817C200ABA4E8 /* yolov8l.mlpackage */ = {isa = PBXFileReference; lastKnownFileType = folder.mlpackage; path = yolov8l.mlpackage; sourceTree = "<group>"; };
6381D2142B7817C200ABA4E8 /* yolov8x.mlpackage */ = {isa = PBXFileReference; lastKnownFileType = folder.mlpackage; path = yolov8x.mlpackage; sourceTree = "<group>"; };
6381D2152B7817C200ABA4E8 /* yolov8s.mlpackage */ = {isa = PBXFileReference; lastKnownFileType = folder.mlpackage; path = yolov8s.mlpackage; sourceTree = "<group>"; };
6381D2162B7817C200ABA4E8 /* yolov8m.mlpackage */ = {isa = PBXFileReference; lastKnownFileType = folder.mlpackage; path = yolov8m.mlpackage; sourceTree = "<group>"; };
6381D2172B7817C200ABA4E8 /* yolov8n.mlpackage */ = {isa = PBXFileReference; lastKnownFileType = folder.mlpackage; path = yolov8n.mlpackage; sourceTree = "<group>"; };
63B8B0A821E62A890026FBC3 /* .gitignore */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = .gitignore; sourceTree = "<group>"; };
730E72CC2BFC43BF000E1F45 /* PostProcessing.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PostProcessing.swift; sourceTree = "<group>"; };
7BCB411721C3096100BFC4D0 /* YOLO.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = YOLO.app; sourceTree = BUILT_PRODUCTS_DIR; };
8EDAA633C1F2B50286D16008 /* BoundingBoxView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BoundingBoxView.swift; sourceTree = "<group>"; };
8EDAAA4507D2D23D7FAB827F /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
Expand All @@ -60,6 +52,7 @@
636166E72514438D0054FA7E /* Utilities */ = {
isa = PBXGroup;
children = (
730E72CC2BFC43BF000E1F45 /* PostProcessing.swift */,
636166E9251443B20054FA7E /* ThresholdProvider.swift */,
8EDAA633C1F2B50286D16008 /* BoundingBoxView.swift */,
);
Expand Down Expand Up @@ -87,11 +80,6 @@
63A946D8271800E20001C3ED /* Models */ = {
isa = PBXGroup;
children = (
6381D2132B7817C200ABA4E8 /* yolov8l.mlpackage */,
6381D2162B7817C200ABA4E8 /* yolov8m.mlpackage */,
6381D2172B7817C200ABA4E8 /* yolov8n.mlpackage */,
6381D2152B7817C200ABA4E8 /* yolov8s.mlpackage */,
6381D2142B7817C200ABA4E8 /* yolov8x.mlpackage */,
);
path = Models;
sourceTree = "<group>";
Expand Down Expand Up @@ -210,13 +198,9 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
6381D21B2B7817C200ABA4E8 /* yolov8m.mlpackage in Sources */,
6381D21C2B7817C200ABA4E8 /* yolov8n.mlpackage in Sources */,
730E72CD2BFC43BF000E1F45 /* PostProcessing.swift in Sources */,
636EFCAF21E62DD300DE43BC /* VideoCapture.swift in Sources */,
636166EA251443B20054FA7E /* ThresholdProvider.swift in Sources */,
6381D2182B7817C200ABA4E8 /* yolov8l.mlpackage in Sources */,
6381D21A2B7817C200ABA4E8 /* yolov8s.mlpackage in Sources */,
6381D2192B7817C200ABA4E8 /* yolov8x.mlpackage in Sources */,
636EFCB321E62DD300DE43BC /* AppDelegate.swift in Sources */,
636EFCAA21E62DD300DE43BC /* ViewController.swift in Sources */,
8EDAA33950796844333D60A7 /* BoundingBoxView.swift in Sources */,
Expand Down Expand Up @@ -351,7 +335,7 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 0;
DEVELOPMENT_TEAM = 3MR4P6CL3X;
DEVELOPMENT_TEAM = MFN25KNUGJ;
INFOPLIST_FILE = YOLO/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Ultralytics YOLO";
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools";
Expand Down Expand Up @@ -379,7 +363,7 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 0;
DEVELOPMENT_TEAM = 3MR4P6CL3X;
DEVELOPMENT_TEAM = MFN25KNUGJ;
INFOPLIST_FILE = YOLO/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Ultralytics YOLO";
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools";
Expand Down
2 changes: 1 addition & 1 deletion YOLO/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>24</string>
<string>29</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSRequiresIPhoneOS</key>
Expand Down
17 changes: 15 additions & 2 deletions YOLO/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22504"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22685"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand Down Expand Up @@ -182,18 +182,30 @@
</items>
<color key="tintColor" white="0.33333333333333331" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</toolbar>
<segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="pGx-Os-eUk">
<rect key="frame" x="261" y="177.66666666666666" width="127" height="32"/>
<segments>
<segment title="Detect"/>
<segment title="Human"/>
</segments>
<connections>
<action selector="taskSegmentControlChanged:" destination="BYZ-38-t0r" eventType="valueChanged" id="XL0-bf-CL7"/>
</connections>
</segmentedControl>
</subviews>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<gestureRecognizers/>
<constraints>
<constraint firstItem="tZo-QP-q2z" firstAttribute="top" secondItem="Gax-hR-qdY" secondAttribute="bottom" constant="1" id="3qP-Re-vUy"/>
<constraint firstItem="pGx-Os-eUk" firstAttribute="centerY" secondItem="Ytf-30-5R8" secondAttribute="centerY" id="CPI-10-mXb"/>
<constraint firstItem="Yhe-73-Ryr" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" constant="6" id="GB3-HN-lcm"/>
<constraint firstItem="lFk-9g-4zt" firstAttribute="top" secondItem="Ovr-pp-CtB" secondAttribute="bottom" id="Sqq-Bb-Nvv"/>
<constraint firstItem="Ovr-pp-CtB" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" constant="5" id="W2U-Xy-2TZ"/>
<constraint firstItem="Gax-hR-qdY" firstAttribute="top" secondItem="Yhe-73-Ryr" secondAttribute="bottom" constant="4" id="WvW-3b-L6y"/>
<constraint firstItem="6JI-Fw-yih" firstAttribute="top" secondItem="tZo-QP-q2z" secondAttribute="bottom" constant="4" id="acL-Dc-cLn"/>
<constraint firstAttribute="trailing" secondItem="3Rg-UC-ogI" secondAttribute="trailing" id="alq-cZ-iIR"/>
<constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" secondItem="pGx-Os-eUk" secondAttribute="trailing" constant="5" id="bQf-TM-PBS"/>
<constraint firstItem="lFk-9g-4zt" firstAttribute="top" secondItem="Ytf-30-5R8" secondAttribute="bottom" constant="28" id="enE-h4-OrG"/>
<constraint firstItem="Ytf-30-5R8" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" constant="8" id="fio-88-KON"/>
<constraint firstItem="3Rg-UC-ogI" firstAttribute="bottom" secondItem="6Tk-OE-BBY" secondAttribute="bottom" id="gd1-rI-r2l"/>
Expand Down Expand Up @@ -223,6 +235,7 @@
<outlet property="slider" destination="Ovr-pp-CtB" id="iHy-z4-EIQ"/>
<outlet property="sliderConf" destination="Gax-hR-qdY" id="KNe-MM-FBA"/>
<outlet property="sliderIoU" destination="6JI-Fw-yih" id="dqE-hH-MVS"/>
<outlet property="taskSegmentControl" destination="pGx-Os-eUk" id="2Fh-eH-HZm"/>
<outlet property="videoPreview" destination="mCE-j4-QAA" id="mP0-Qx-oq6"/>
</connections>
</viewController>
Expand Down
36 changes: 31 additions & 5 deletions YOLO/Utilities/BoundingBoxView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class BoundingBoxView {
/// The layer that displays the label and confidence score for the detected object.
let textLayer: CATextLayer

/// The layer that displays the inner text within the bounding box.
let innerTextLayer: CATextLayer

/// Initializes a new BoundingBoxView with configured shape and text layers.
init() {
shapeLayer = CAShapeLayer()
Expand All @@ -33,22 +36,32 @@ class BoundingBoxView {
textLayer.fontSize = 14 // Set font size for the label text
textLayer.font = UIFont(name: "Avenir", size: textLayer.fontSize) // Use Avenir font for labels
textLayer.alignmentMode = .center // Center-align the text within the layer

innerTextLayer = CATextLayer()
innerTextLayer.isHidden = true // Initially hidden; shown with label when a detection occurs
innerTextLayer.contentsScale = UIScreen.main.scale // Ensure the text is sharp on retina displays
innerTextLayer.fontSize = 12 // Set font size for the inner text
innerTextLayer.font = UIFont(name: "Avenir", size: innerTextLayer.fontSize) // Use Avenir font for inner text
innerTextLayer.alignmentMode = .left // Left-align the text within the layer
innerTextLayer.isWrapped = true // Wrap the text to fit within the layer
}

/// Adds the bounding box and text layers to a specified parent layer.
/// - Parameter parent: The CALayer to which the bounding box and text layers will be added.
/// Adds the bounding box, text, and inner text layers to a specified parent layer.
/// - Parameter parent: The CALayer to which the bounding box, text, and inner text layers will be added.
func addToLayer(_ parent: CALayer) {
parent.addSublayer(shapeLayer)
parent.addSublayer(textLayer)
parent.addSublayer(innerTextLayer)
}

/// Updates the bounding box and label to be visible with specified properties.
/// Updates the bounding box, label, and inner text to be visible with specified properties.
/// - Parameters:
/// - frame: The CGRect frame defining the bounding box's size and position.
/// - label: The text label to display (e.g., object class and confidence).
/// - color: The color of the bounding box stroke and label background.
/// - alpha: The opacity level for the bounding box stroke and label background.
func show(frame: CGRect, label: String, color: UIColor, alpha: CGFloat) {
/// - innerTexts: The text to display inside the bounding box.
func show(frame: CGRect, label: String, color: UIColor, alpha: CGFloat, innerTexts: String) {
CATransaction.setDisableActions(true) // Disable implicit animations

let path = UIBezierPath(roundedRect: frame, cornerRadius: 6.0) // Rounded rectangle for the bounding box
Expand All @@ -69,11 +82,24 @@ class BoundingBoxView {
let textSize = CGSize(width: textRect.width + 12, height: textRect.height) // Add padding to the text size
let textOrigin = CGPoint(x: frame.origin.x - 2, y: frame.origin.y - textSize.height - 2) // Position above the bounding box
textLayer.frame = CGRect(origin: textOrigin, size: textSize) // Set the text layer frame

if !innerTexts.isEmpty {
innerTextLayer.string = innerTexts // Set the inner text
innerTextLayer.backgroundColor = UIColor.clear.cgColor // No background color
innerTextLayer.isHidden = false // Make the inner text layer visible
innerTextLayer.foregroundColor = UIColor.red.cgColor // Set text color
innerTextLayer.frame = CGRect(x: frame.origin.x + 4, y: frame.origin.y + 4, width: frame.width / 2 - 8, height: frame.height - 8)
// Set the inner text layer frame
} else {
innerTextLayer.isHidden = true // Hide the inner text layer if innerTexts is empty
}

}

/// Hides the bounding box and text layers.
/// Hides the bounding box, text, and inner text layers.
func hide() {
shapeLayer.isHidden = true
textLayer.isHidden = true
innerTextLayer.isHidden = true
}
}
Loading
Loading