Skip to content

sjrankin/BlockCam

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

618 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

3D Block Camera

BlockCam is a camera program for iOS and iPadOS that takes images via AVFoundation and then converts those images into simple 3D scenes. The scenes may be rotated and scaled by the user, and saved as a flat image.

BlockCam was written by Stuart Rankin.

Versioning

Versioning for BlockCam is maintained in the Versioning.swift file and is automatically updated with each build as a pre-build script step. The updating includes build IDs, build numbers, times and dates, but version numbers must currently be updated by hand. The current build string below is also maintained by the same mechanism.

The versioning program does not currently update the BlockCam project file's version numbers.

Most recent build: Version 0.9 Alpha, Build 3287, Build date: 13 July 2021, 16:06

See VersionUpdater repository on GitHub for information on how versions and builds are updated.

Privacy

BlockCam is designed to contain user-supplied information as much as possible. Any time user-identifiable information is used, BlockCam will ask for it explicitly. By design, BlockCam does not collect any user-identifiable information by default; the user must take active steps to allow collection of this type of information.

Identifiable Information Use Storage
User Name The user's name (entered by the user) to be stored in processed image metadata. Stored in UserDefaults.
User Copyright The user's copyright string (entered by the user) to be stored in processed image metadata. Stored in UserDefaults.

Program Flow

When the user instantiates BlockCam, it opens in live view mode (showing the view of the camera on the main screen). The user has the option of choosing one of three modes:

  1. Live View Mode This is the default mode and allows the user to take pictures of whatever the program shows. Once the picture is taken, it is processed then displayed in the view.
  2. Album Mode This mode allows the user to select an image from the camera roll on the device. That image is then processed the same way as a live view image would be. The user can also convert an existing video.
  3. Video Mode Not currently implemented. This mode allows users to make videos with the normal iOS/iPadOS video interface and process the video using the current settings.
  4. Processed Mode Not currently implemented. This is intended to allow the user to view the output of the live view feed processed into a 3D scene. Given the slowness of the processing, this may not be feasible except for when running on faster, future platforms (or on a desktop system).

Platforms

BlockCam has been tested on the following platforms:

  • iPhone 6S+ with iOS 13.3
  • iPhone 8 with iOS 13.3
  • iPad Mini 4 with iPadOS 13.3
  • iPad Pro 9.7 with iPadOS 13.3
  • macOS 10.15.2 via MacCatalyst (see, however, Issues).

Issues

  1. The main issue is one of performance. When used on images of large size on older cell phones, performance slows dramatically. However, the selfie camera is actually very quick. BlockCam has certain mitigations in place (such as user settings) to help reduce some performance issues.
  2. Kanji is extraordinarily slow. To create an extruded image using kanji characters takes on the order of 6 minutes for an older iPhone.
  3. Only tested on the following: iPhone 6S+, iPhone 8, iPad Mini 4. iPad Pro 9.7.
  4. MacCatalyst does not support AVFoundation usage of the Mac camera, making things quite difficult. Work on the MacCatalyst version has stopped for now due to that impedement.
  5. Histograms are not yet implemented.
  6. Non-built-in geometric shapes seem to perform significantly slower than built-in shapes.
  7. iPadOS and iOS 13 seem to have a few extra debug statements left in them that lead to confusing debug sessions - specifically, "Can't end BackgroundTask" messages.

Future Plans

  1. Add more shapes, such as stars or hearts and the like.
  • Stars added - use UIBezierPath to add more shapes.
  1. Add a processed-live view mode that shows a live view (similar to the photo mode right now) only processed. This will probably be very power hungry and slow and may work reliably only on the most recent hardware.
  2. Share videos - right now, only images can be shared.
  3. Fully implement usage of pixellated data. Most code is in place. This feature saves processed image data at the pixellation level (eg, colors for each pixel region) as a file in the user's file system space. The advantage is to quicken processing when the user changes certain settings, such as shape or extrusion depth. Done.

Performance

There are four performance concerns for BlockCam:

  1. Memory This concern is mainly for video processing. Currently, BlockCam reads all frames of a video to process and resizes them as required, saving resized images in memory. By placing memory-intensive code in loops in autoreleasepool blocks, most concerns have been addressed. If it turns out that this is insufficient, a mitigation plan exists: Save all scratch images to local storage then read them singly and process them one at a time. This will slow things down but reduce memory pressure.
  2. Time It takes a significant amount of time to process one image, especially if that image is large. The user interface provides controls for the user to reduce the size of the image to process. Additionally, the user interface provides hints to the user with respect to which options are slower than others.
  3. Thermal Since BlockCam makes heavy use of the graphics processor, it is possible to overheat the device. When this happens (and if default settings have not been changed), BlockCam will immediately exit when the thermal condition becomes critical.
  4. Power Due to the same causes of thermal issues, the battery may be drained quickly when using BlockCam. If default settings are in place and the device enters a low power state, BlockCam will immediately exit.

Theory of Operation

BlockCam converts each image that is taken into a pixellated image via CoreImage filter CIPixellate. After pixellation, the processing algorithm then calculates the height determinate - the height determines either the size of a node or the extrusion of a node. Then, each pixel from the pixellated image is converted into a 3D shape (set by the user) and then added to the current scene in the 3D view.

All processing operations make use of the same code but may be called differently (or multiple times) depending on the user-facing mode in effect.

Step 1: Image Acquisition

An image is acquired for processing. The source of the image is not important so long as it is a standard, iOS/iPadOS-readable image. The most common source of images will most likely be the live view camera. Other sources are the photo album and video frames.

The following image is the source for the processing. (This is an image I took of our garden in early winter.)

Original image

Step 2: Image Conditioning

Given the performance expense of converting the image, the user has the option of reducing the amount of work done by having the source image resized to a smaller size. This may also occur without the user's intervention should videos be processed. (Processing videos tends to take a lot of memory, so even saving a few percent per image will help keep things less stressful on the system.) Some images are also rotated to 270° (or -90° if you prefer) and need to be rotated correctly. This is also done in the image conditioning step.

Step 3: Image Pixellation

The processed image is then pixellated via Core Image filter functions. Specifically, the most common filter BlockCam uses is CIPixellate (although other pixellation filters are used depending on the final shape). The size of each pixellated region is depending on user settings. The smaller the size, the greater the impact on overall performance, though CIPixellate (and like filters) are still very fast. The reason why smaller pixellated regions increase performance is because more 3D nodes will be required later on.

The following image shows the pixellation of the original image. Note that each pixellated region is a solid color, which means BlockCam does not have to read the entire region to get the color - just one pixel.

Pixellated image sample

Step 4: Image Parsing

The pixellated image is then parsed. This entails getting the color of each pixellated region. This is a slower than expected step. Getting individual pixel data from an image requires a great deal of image data manipulation just to get the image ready to be queried. At the end of this step, images are no longer used. A 2D array of color data is passed to the next step.

At this step, pixellated image data is saved to local file storage. This is to simplify minor visual changes later requested by the user.

Step 5: 3D Node Generation

The final node shape is a user setting. BlockCam allows users to select from one of many shapes - the built-in shapes tend to run faster than non-built-in shapes (for example, spheres are faster than pentagons). A 3D node is generated for each color from the Image Parsing step using the specified geometry. In order to show off the 3D-ness of the final scene, nodes are exaggerated in some dimension. For example, if cubes are the shape selected by the user, the length will be exaggerated. Exaggeration is determined by the color - the color is used to shade the diffuse surface of the node as well as to determine the height. Exaggeration is determined by a user-selectable determinant:

  • Hue - The hue determines the exaggeration. This tends to lead to reds that are very tall as well as very short, given where reds live in the HSB hue circle.
  • Saturation - Brightly color pixellated areas tend to be highlighted.
  • Brightness - This is the default determinant and probably the best - the brightness of the color of the pixellate region determines the exaggeration so bright areas are highest.
  • Red, Green, Blue - The specified RGB color channel is used as the exaggeration determinant.
  • Cyan, Magenta, Yellow, Black - The specified CMYK color channel is used as the exaggeration determinant (with Black leading to some very strange-looking results). (While some calculation is required to convert from RGB to CMYK, the amount is relatively minor and does not adversely affect performance.)

Once a node has been created, it is added to a master node. Once all nodes have been created and placed in to the master node, the master node itself is placed in to the 3D scene.

  • A master node is used to make later animations an order of magnitude easier to manage.

Step 6: Display

While this may seem a trivial step, it is very tricky when converting videos. If converting an image, All that happens is the 3D scene is updated and eventually shown to the user (usually within 0.5 to 2.0 seconds). For videos, it is critical to get the timing of the display right: to convert a video, each frame is run through these steps and then a snapshot is taken of the 3D scene. If the snapshot is taken before the scene has been displayed, the result will be a pure black image, which isn't what the user wants to see. Therefore, BlockCam must participate in the SCNSceneRendererDelegate set of functions to know when a scene is actually visible to the user.

The following image is the final, processed version of the image. This is the output of a snapshot() call on the SCNView. The sample uses extruded blocks and is being viewed in the default camera orientation.

Processed image

Step 7: Image Disposition

Once the image is display, the user has the option to save it as is or edit some visual aspects or rotate or zoom in or out, and then save it (again, perhaps). For videos, once a snapshot of the 3D scene is captured, the scene is disposed of.

Step 7a: Saving Processed Images

Depending on the value of .SaveOriginalImageAction, the original image will be saved. When the user saves the processed image, metadata is saved along with the processed image. The metadata consists of the name and version of the program as well as the parameters in effect when the image was created.

Saving processed files is a multi-step process:

  1. The image is saved in the /Scratch directory as a standard .jpg file.
  2. Metadata is added to the saved image which is then resaved as a different file (still as a .jpg file).
  3. The original file is deleted.
  4. The modified file is then copied to the photo roll (using PHAssetCreationRequest with the appropriate parameters set - this is needed because the more common method to move images to the photo roll strips Exif data).
  5. On success, the modified is deleted from the /Scratch directory.

Metadata

BlockCam saves metadata in processed files.

Group Tag Stored values
TIFF Artist If enabled by the user, the user's name.
TIFF Copyright If enabled by the user, the user's copyright string.
TIFF Software BlockCam's name, version, and build numbers.
Exif UserComment List of parameters used to generate the processed image.

See also the Privacy discussion.

Flow Diagrams

Image Flow

A simplified flow diagram for image processing is shown below.

Simplified image flow

Performance Optimization

Due to the amount of time it takes to preprocess and pixellate an image, every time a new image is processed, pixellation data (consisting of an array of colors) is saved to the device's file system. If the user then changes a parameter (such as a 3D shape), preprocessing has already been completed and the pixellation data is reused. This can potentially save a great deal of time.

If the user changes a parameter that affects preprocessing, the image is reprocessed from the beginning. (For example, the changing the block size will cause a full reprocessing cycle to be executed.)

Video Flow

A simplified flow diagram for video processing is shown below. The cube refers back to the Image Flow.

Simplified video flow

Currently, the green box ("Processed Frame") does not function as expected/required so as of current writing, video creation is not supported.

Logging

BlockCam logs messages and status at runtime to the debug console (if present, and in the vast majority of instances, this will not be present) and to a local SQLite database. This allows for post-mortem debugging should the need arise.

Given Apple's policy on data rentention (not to mention the EU's policies), it is entirely likely logging will be removed (via compile-time flags) for any released version of BlockCam.

Settings

All user settings (and a few process settings) are stored via the Settings class. This class encapsulates a storage mechanism that is invisible to the rest of the program. Currently, the storage mechanism is UserDefaults. Should settings become more complex, it is straightforward to migrate this to a database.

To access settings, callers must use the provided methods of the Settings class. This helps to ensure data type integrity.

The Settings class also provides setting-level notification of changes (which was the primary reason to create the class in the first place).

Settings Dictionary

BlockCam settings are presented below.

Symbol Type Default Usage
.Initialized String "Initialized" Flag that determines whether settings have been initialized or not. When BlockCam first runs, if .Initialized is nil or empty, it assumes it is the first time BlockCam has been run and so therefore writes default values for all settings.
.BlockSize Integer 48 Block size for image processing. This is the square size of each pixellated region.
.ShapeType String "Blocks" The same of the 3D object at each pixellation region. Cast from an enum.
.InvertHeight Boolean false The invert height/size determination flag.
.HeightSource String "Brightness" The color channel to use to determine height/size. Cast from an enum.
.ImageSizeConstraints String "Medium" Determines the amount of reduction in size of the image to do before processing it for performance reasons. Cast from an enum. Actual value interpreted at run time.
.VerticalExaggeration String "Medium" The amount of vertical exaggeration to perform when extruding or enlarging 3D shapes. Cast from an enum.
.InputQuality Integer 2 Value that indicates the input quality. Ranges from 0 to 3 with 3 being the highest quality (and slowest to process).
.CurrentCamera String "Back" The position of the last camera used. Either front or back. Cast from an enum.
.LightColor String "White" Name of the color of the light. Cast from an enum. May be converted to a color library type of color later.
.LightType String "Omni" Name of the type of light used to illuminate the scene. Cast from an enum.
.LightIntensity String "Normal" Intensity of the light used to illuminate the scene. Actual value determined at runtime. Cast from an enum.
.FieldOfView String "Normal" Field of view of the camera. Actual value is determined at runtime. Cast from an enum.
.ShowHistogram Boolean false Show the histogram display. Not currently implemented.
.HistogramBucketCount Integer 256 Number of colors in the histogram display. Not currently implemented.
.InitialView String "LiveView" The last view seen by the user (such as live view, albums, etc).
.FullyExtrudeLetters Boolean true Determines if letters are fully extruded or only partially extruded.
.LetterSmoothness String "Smooth" Determines how smoothly to create curves in letters. High quality curves comes at a large performance cost. Actual value determined at runtime. Cast from an enum.
.LetterFont String "Futura" The font (and optional weight) to use to render extruded letters. If the font does not exist on the system, BlockCam will enter an undefined state.
.RandomCharacterSource String "Latin" Named Unicode range of characters to use as a source for random letters when extruding characters. Multiple ranges may be specified by separating each from the others with a comma.
.VideoFPS Integer 1 Not currently used.
.VideoDimensions String "Smallest" Determines the final video size when generating video. Actual value determined at runtime. Cast from an enum.
.VideoBlockSize Integer 48 Block size for video processing. This is the square size of each pixellated region.
.UseMetal Boolean true Flag that tells BlockCam to use Metal rather than OpenGL.
.AntialiasingMode Integer 0 Determines the antialiasing mode.
.InitialBestFit Boolean false If true, BlockCam will try to fit all nodes into the view with as tightly as possible.
.SaveOriginalImageAction String "Always" Determines how and when to save original images. Cast from an enum.
.NextSequentialInteger Integer 0 Used for file name generation.
.LoopSequentialIntegerAfter Integer 9999 Determines when to loop to the start when using sequential integers.
.StartSequentialIntegerAt Integer 1 Starting value for sequential integers.
.IncreaseStarApexesWithProminence Boolean false If true, the number of apexes for star shapes increases with the prominence of the color height.
.StarApexCount Integer 5 Number of apexes for stars. If .IncreaseStarApexesWithProminence is true, this is the starting number of apexes.
.HaltWhenCriticalThermal Boolean true If true, BlockCam will halt (via a fatalError call) when it receives a critical thermal alert. This may violate Apple guidelines and may be removed.
.HaltOnLowPower Boolean true If true, BlockCam will halt (via a fatalError call) when it receives a low power alert. This may violate Apple guidelines and may be removed.
.BestFitOffset Double 2.0 Value to use to back the camera away when .InitialBestFit is true to give a bit more negative space to the image.
.LightingModel String "Phong" Surface material lighting model. Cast from an enum.
.CappedLineBallLocation String "Top" Location of the ball ("cap") for CappedLine shaped nodes. Cast from an enum.
.LoggingEnabled Boolean false Enable logging flag.
.FontSize Integer 36 The font size for extruded letters.
.EnableUISounds Boolean true Flag to play UI sounds (such as when a button is pressed). If this value is false, all other sound flags are ignored.
.EnableShutterSound Boolean false Flag to play a shutter sound when the camera button is pressed. In some geographic locations, this always happens and setting this value will have no effect.
.EnableImageProcessingSound Boolean true Flag to play a sound at the start and end of image processing. Since image processing is time-consuming, this helps the user understand when the image is completed.
.EnableVideoRecordingSound Boolean true Flag to play a sound when the user starts and stops recording a video.
.EnableButtonPressSounds Boolean true Flag to play a sound when the user presses buttons.
.EnableOptionSelectSounds Boolean true Flag to play a sound when the user selects an option in the on-screen settings display.
.EnableCrashSounds Boolean false Flag to play a sound when a crash dialog is shown. Enabled only when compiled in #DEBUG mode.
.MeshDotSize String "Medium" Size of the center dot for meshes. If .None is used, no center dot will be displayed. Cast from an enum.
.MeshLineThickness String "Medium" Thickness of mesh lines. Cast from an enum.
.RadiatingLineThickness String "Medium" Thickness of radiating line shapes. Cast from an enum.
.RadiatingLineCount Integer 8 Number of radiating lines in a radiating line shape. 4 is for lines pointing towards the cardinal directions, 8 for the cardinal directions and inbetween, and 16 for 8 more lines in the z-plane.
.BlockChamferSize String "None" The chamfer radius/edge smoothness for block shapes. Cast from an enum.
.MaxImageDimension Integer 1024 Maximum dimension of an image. If an image to process is larger, it will be resized such that the longest dimension is this value.
.AddUserDataToExif Boolean false Flag to add user-created information to processed images' Exif block. If compiled in #DEBUG mode, this value defaults to true.
.UserName String "" (Default is blank.) The user-supplied name that is added to processed images' Exif block. This happens only if .AddUserDataToExif is true. If compiled in #DEBUG mode, this value defaults to "Stuart Rankin".
.UserCopyright String "" (Default is blank.) The user-supplied copyright string that is added to processed images' Exif block. This happens only if .AddUserDataToExif is true. If compiled in #DEBUG mode, this value defaults to "Attribution 3.0 Unported (CC BY 3.0)".
.ConeIsInverted Boolean true Determines if cone-shapes are inverted in terms of z depth.
.ConeTopOptions String .TopIsZero.rawValue Options for determining the top radius of the cone.
.ConeBaseOptions String .BaseIsSide.rawValue Options for determining the base radius of the cone.
.ShowSplashScreen Boolean true Flag that determines whether the splash screen is shown at start up or not.
.HueShapeList String "" List of shapes for the hue variant shape type.
.SaturationShapeList String "" List of shapes for the saturation variant shape type.
.BrightnessShapeList String "" List of shapes for the brightness variant shape type.

System Management

BlockCam uses 3D processing, which exercises the device's graphics chip. If the user specifies highest quality settings, it is possible certain extreme conditions may occur. To help preserve the device from damage, settings are available to abort execution of BlockCam when that happens.

Event Action Controlling Setting
Thermal If a thermal event reaches the critical stage (literally .critical in the notification), if the setting is true, a fatal error will be generated to reduce any thermal stress created by BlockCam. .HaltWhenTooHot
Battery If the battery enters a low power state, if the setting is true, a fatal error will be generated to help preserve the battery's life before recharging. .HaltOnLowPower

Supported Visuals

BlockCam supports the following visuals:

Shapes

The following shapes are currently supported (or planned to be supported) for extrusion effects:

Shape Native Notes
Blocks Yes - SCNBox Native box shapes lengthened along the Z axis.
Triangles No Custom equilateral triangle shapes.
Pentagons No Custom equilateral pentagon shapes.
Hexagons No Custom equilateral hexagonal shapes.
Octogons No Custom equilateral octagonal shapes.
Pyramids Yes - SCNPyramid Native pyramid shapes.
Toroids Yes - SCNTorus Native torus shapes.
Cylinders Yes - SCNCylinder Native cylinder shapes - makes for nice elevated circles.
Spheres Yes - SCNSphere Native sphere shapes.
Capsules Yes - SCNCapsule Native capsule shapes. Not as interesting as they sound.
Tetrahedrons No Custom equilateral tetrahedron solid.
Stars No Custom star shapes (with radially equal apexes). Can vary the number of apexes.
CombinedForRGB Yes - combination Combined sphere, torus, and capsule.
CombinedForHSB Yes - combination Combined sphere, torus, and capsule.
Meshes No Not currently implemented.
Letters Yes - SCNText Native extruded text. Tends to be extraordinarily slow, especially with non-Latin alphabets.
Lines Yes - SCNCapsule Very thin capsule shape.
CappedLines Yes - combination Very thin capsule shape with a sphere placed at the top, middle, or bottom of the line depending on user settings.
RadiatingLines Yes - combination Multiple lines radiating from the center point. User can specify how many lines. This is a performance-heavy shape.
HueVarying variants The shape at a given point is determined by the hue of the pixellated region so the actual final shape will vary.
SaturationVarying variants The shape at a given point is determined by the saturation of the pixellated region so the actual final shape will vary.
BrightnessVarying variants The shape at a given point is determined by the brightness of the pixellated region so the actual final shape will vary.

Extrusions/Depth Determination

Each shape for a representative pixellated region is extruded or enlarged. The determination of the extrusion depth or enlarged size depends on the color of the pixellated region.

Color Channel Usage
Hue The hue of the color determines the depth/size of the 3D object. Note that hue values are cyclical (with 0.0 being essentially the same as 1.0) so reddish pixels tend to be subdued while green are highlighted.
Saturation The color saturation value determines depth/size. Brighter colors will be bigger.
Brightness The brightness of the color determines depth/size. This is the default value and how most people would expect the program to work.
Red The red channel is used to determine depth/size.
Green The green channel is used to determine depth/size.
Blue The blue channel is used to determine depth/size.
Cyan A synthetic cyan channel (from CMYK) is used to determine depth/size.
Magenta A synthetic magenta channel (from CMYK) is used to determine depth/size.
Yellow A synthetic yellow channel (from CMYK) is used to determine depth/size.
Black A synthetic black channel (from CMYK) is used to determine depth/size.
YUV: Y The synthetic Y channel from a YUV conversion.
YUV: U The synthetic U channel from a YUV conversion.
YUV: V The synthetic V channel from a YUV conversion.

BlockCam supports an inverted flag. This means if the user sets invert, the depth/size is a reciprocol of itself, making dark areas prominent and light areas subdued or hidden.

Lighting

BlockCam supports changing the color of the light as well as the type of the light. Colors are currently restricted to a small set of pre-defined colors. The types of lights parallel SceneKit's standard, non-parametized lights (such as .omni and .spot).

The light's position is not currently adjustable by the user.

Image Rotation

BlockCam makes use of SCNView's allowsCameraControl flag to let the user enlarge, shink, or rotate (in three axes) by way of gestures.

When initially rendered, the result may appear to be relatively far away from the view. BlockCam has a user-settable flag to fit the image to the view. This feature tends to confuse allowsCameraControl with respect to enlarging and shrinking.

Implementation

This section will discuss various implementation-level details.

Source

BlockCam was written in Swift 5 with Xcode 11.3.

Threading

Given the lengthy amount of time it takes to process images, all image processing is done on a background thread. This requires all communication to update the user via the UI to be done with the proper threading calls.

Project Structure

TBD

Legal

BlockCam is copyright © 2019, 2020 by Stuart Rankin


Block_Cam

日本語版 «Google翻蚳で翻蚳»

3Dブロックカメラ

BlockCamはiOSおよびiPadOS甚のカメラプログラムで、AVFoundationを介しお画像を取埗し、それらの画像を単玔な3Dシヌンに倉換したす。シヌンは、ナヌザヌによっお回転および拡倧瞮小され、フラットむメヌゞずしお保存されたす。

BlockCamはStuart Rankinによっお䜜成されたした。

バヌゞョン管理

BlockCamのバヌゞョン管理は Versioning.swiftファむルで管理され、ビルド前のスクリプトステップずしおビルドごずに自動的に曎新されたす。 曎新にはビルドID、ビルド番号、時刻、日付が含たれたすが、珟圚、バヌゞョン番号は手動で曎新する必芁がありたす。 以䞋の珟圚のビルド文字列も同じメカニズムによっお維持されたす。

珟圚、バヌゞョン管理プログラムはBlockCamプロゞェクトファむルのバヌゞョン番号を曎新したせん。

最新のビルドバヌゞョン情報に぀いおは、英語のセクションを参照しおください。

バヌゞョンずビルドの曎新方法に぀いおは、GitHubの[VersionUpdater]https://github.com/sjrankin/VersionUpdaterリポゞトリを参照しおください。

プラむバシヌ

BlockCamは、可胜な限りナヌザヌが提䟛する情報を含むように蚭蚈されおいたす。 ナヌザヌを特定できる情報が䜿甚されるたびに、BlockCamはそれを明瀺的に芁求したす。 蚭蚈䞊、BlockCamはデフォルトでナヌザヌを特定できる情報を収集したせん。 ナヌザヌは、このタむプの情報の収集を蚱可するためにアクティブな手順を実行する必芁がありたす。

識別情報 䜿甚 保管
ナヌザヌ名 凊理された画像のメタデヌタに保存されるナヌザヌの名前ナヌザヌが入力。 「UserDefaults」に保存されたす。
ナヌザヌ著䜜暩 凊理された画像メタデヌタに保存されるナヌザヌの著䜜暩文字列ナヌザヌが入力。 「UserDefaults」に保存されたす。

プログラムの流れ

ナヌザヌがBlockCamをむンスタンス化するず、ラむブビュヌモヌドで開きたすメむン画面にカメラのビュヌを衚瀺。ナヌザヌには、次の3぀のモヌドのいずれかを遞択するオプションがありたす。

  1. ラむブビュヌモヌドこれはデフォルトのモヌドであり、ナヌザヌはプログラムが衚瀺するものを䜕でも写真に撮るこずができたす。 写真が撮圱されるず、凊理されおビュヌに衚瀺されたす。
  2. アルバムモヌドこのモヌドでは、ナヌザヌはデバむスのカメラロヌルから画像を遞択できたす。 その画像は、ラむブビュヌ画像ず同じ方法で凊理されたす。 ナヌザヌは既存のビデオを倉換するこずもできたす。
  3. ビデオモヌド 珟圚実装されおいたせん。 このモヌドでは、ナヌザヌは通垞のiOS / iPadOSビデオむンタヌフェむスでビデオを䜜成し、珟圚の蚭定を䜿甚しおビデオを凊理できたす。 4. 凊理モヌド 珟圚実装されおいたせん。 これは、3Dシヌンに凊理されたラむブビュヌフィヌドの出力をナヌザヌが衚瀺できるようにするこずを目的ずしおいたす。 凊理が遅いこずを考えるず、これは、より高速の将来のプラットフォヌムたたはデスクトップシステムで実行する堎合を陀いお、実行䞍可胜な堎合がありたす。

プラットフォヌム

BlockCamは、次のプラットフォヌムでテストされおいたす。

  • iOS 13.3を搭茉したiPhone 6S +
  • iOS 13.3を搭茉したiPhone 8
  • iPadOS 13.3を搭茉したiPad Mini 4
  • iPadOS 13.3を搭茉したiPad Pro 9.7

問題

1.䞻な問題はパフォヌマンスです。 叀い携垯電話の倧きなサむズの画像で䜿甚するず、パフォヌマンスが倧幅に䜎䞋したす。 ただし、セルフィヌカメラは実際には非垞に高速です。 BlockCamには、パフォヌマンスの問題を軜枛するのに圹立぀特定の軜枛策ナヌザヌ蚭定などがありたす。 2. *挢字は非垞に遅いです。*挢字を䜿甚しお抌し出し画像を䜜成するには、叀いiPhoneの堎合、6分皋床かかりたす。 3.以䞋でのみテスト枈みiPhone 6S +、iPhone 8、iPad Mini4。iPadPro 9.7。 4. MacCatalystは、MacカメラのAVFoundationの䜿甚をサポヌトしおいないため、非垞に困難です。 MacCatalystバヌゞョンでの䜜業は、その劚害のため珟圚のずころ停止しおいたす。 5.ヒストグラムはただ実装されおいたせん。 6.非組み蟌みの幟䜕孊的図圢は、組み蟌みの図圢よりも倧幅に遅いように芋えたす。 7. iPadOSおよびiOS 13には、混乱するデバッグセッションに぀ながるいく぀かの远加のデバッグステヌトメントが残っおいるようです。具䜓的には、「BackgroundTaskを終了できたせん」メッセヌゞです。

今埌の蚈画

  1. 星やハヌトなどの図圢を远加したす。   -スタヌが远加されたした-UIBezierPathを䜿甚しおさらにシェむプを远加したす。   2.凊理枈みのラむブビュヌ珟圚の写真モヌドず同様のみを衚瀺する凊理枈みラむブビュヌモヌドを远加したす。 これはおそらく非垞に電力を消費し、遅くなり、最新のハヌドりェアでのみ確実に動䜜する可胜性がありたす。   3.ビデオを共有する-珟圚、画像のみを共有できたす。   4.ピクセル化されたデヌタの䜿甚を完党に実装したす。 ほずんどのコヌドが配眮されおいたす。 この機胜は、凊理された画像デヌタをピクセル化レベルたずえば、各ピクセル領域の色でナヌザヌのファむルシステム空間にファむルずしお保存したす。 利点は、圢状や抌し出しの深さなどの特定の蚭定をナヌザヌが倉曎したずきに凊理を高速化するこずです。

パフォヌマンス

BlockCamには、パフォヌマンスに関する4぀の懞念事項がありたす。

  1. メモリこの懞念は䞻にビデオ凊理に関するものです。珟圚、BlockCamはビデオのすべおのフレヌムを読み取っお凊理し、必芁に応じおサむズを倉曎しお、サむズ倉曎された画像をメモリに保存したす。メモリを倧量に消費するコヌドを「autoreleasepool」ブロックのルヌプに配眮するこずで、ほずんどの懞念事項に察凊したした。これが䞍十分であるこずが刀明した堎合、軜枛蚈画が存圚したす。すべおのスクラッチむメヌゞをロヌカルストレヌゞに保存し、それらを1぀ず぀読み取り、䞀床に1぀ず぀凊理したす。これにより速床は䜎䞋したすが、メモリの負荷は軜枛されたす。
  2. 時間 1぀の画像の凊理には、特にその画像が倧きい堎合、かなりの時間がかかりたす。ナヌザヌむンタヌフェむスは、凊理する画像のサむズを瞮小するためのコントロヌルをナヌザヌに提䟛したす。さらに、ナヌザヌむンタヌフェむスは、他のオプションよりも遅いオプションに関しおナヌザヌにヒントを提䟛したす。
  3. 熱 BlockCamはグラフィックプロセッサを倚甚するため、デバむスが過熱する可胜性がありたす。これが発生した堎合およびデフォルト蚭定が倉曎されおいない堎合、枩床条件が重倧になるずBlockCamはすぐに終了したす。
  4. 電力熱問題の同じ原因により、BlockCamを䜿甚するず、バッテリヌがすぐに消耗する堎合がありたす。デフォルト蚭定が蚭定されおいお、デバむスが䜎電力状態になるず、BlockCamはすぐに終了したす。

操䜜の理論

BlockCamは、取り蟌たれた各画像をCoreImageフィルタヌ CIPixellateを介しおピクセル化された画像に倉換したす。 ピクセル化の埌、凊理アルゎリズムは高さの決定を蚈算したす-高さはノヌドのサむズたたはノヌドの抌し出しを決定したす。 次に、ピクセル化された画像の各ピクセルが3D圢状ナヌザヌが蚭定に倉換され、3Dビュヌの珟圚のシヌンに远加されたす。

すべおの凊理操䜜は同じコヌドを䜿甚したすが、有効なナヌザヌ向けモヌドに応じお異なる方法たたは耇数回で呌び出すこずができたす。

ステップ1画像の取埗

凊理のために画像が取埗されたす。画像の゜ヌスは、iOS / iPadOSで読み取り可胜な暙準の画像である限り重芁ではありたせん。画像の最も䞀般的な゜ヌスは、おそらくラむブビュヌカメラです。他の゜ヌスは、フォトアルバムずビデオフレヌムです。

次の画像は、凊理の゜ヌスです。 これは私が初冬に庭で撮った画像です。

元の画像

ステップ2画像調敎

画像を倉換するためのパフォヌマンスの犠牲を考えるず、ナヌザヌは゜ヌス画像をより小さなサむズにサむズ倉曎するこずにより、実行される䜜業量を削枛するオプションがありたす。これは、ビデオが凊理される堎合、ナヌザヌの介入なしに発生するこずもありたす。 ビデオの凊理は倚くのメモリを消費する傟向があるため、画像ごずに数パヌセントを保存しおもシステムのストレスを軜枛できたす。䞀郚の画像は270°たたは必芁に応じお-90°に回転され、正しく回転したす。これは、画像調敎ステップでも行われたす。

ステップ3画像のピクセル化

凊理された画像は、Core Imageフィルタヌ関数を介しおピクセル化されたす。具䜓的には、BlockCamが䜿甚する最も䞀般的なフィルタヌは「CIPixellate」ですただし、最終的な圢状に応じお他のピクセル化フィルタヌが䜿甚されたす。各ピクセル化領域のサむズは、ナヌザヌ蚭定によっお異なりたす。サむズが小さいほど、党䜓的なパフォヌマンスぞの圱響は倧きくなりたすが、「CIPixellate」およびフィルタヌず同様は䟝然ずしお非垞に高速です。ピクセル化された領域が小さくなるずパフォヌマンスが向䞊する理由は、埌でより倚くの3Dノヌドが必芁になるためです。

次の画像は、元の画像のピクセル化を瀺しおいたす。各ピクセル化された領域は単色であるこずに泚意しおください。぀たり、BlockCamは領域党䜓を読み取っお色を取埗する必芁はなく、1ピクセルだけです。

ピクセル化された画像サンプル

ステップ4画像解析

次に、ピクセル化された画像が解析されたす。これには、ピクセル化された各領域の色を取埗する必芁がありたす。これは予想よりも遅いステップです。画像から個々のピクセルデヌタを取埗するには、画像を照䌚できるようにするためだけに倧量の画像デヌタ操䜜が必芁です。この手順の最埌に、画像は䜿甚されなくなりたす。カラヌデヌタの2D配列が次のステップに枡されたす。

このステップでは、ピクセル化された画像デヌタがロヌカルファむルストレヌゞに保存されたす。 これは、埌でナヌザヌが芁求する小さな芖芚的な倉曎を簡玠化するためです。

ステップ53Dノヌドの生成

最終的なノヌド圢状はナヌザヌ蚭定です。 BlockCamを䜿甚するず、ナヌザヌは倚くの圢状のいずれかを遞択できたす。組み蟌みの圢状は、非組み蟌みの圢状よりも速く動䜜する傟向がありたすたずえば、球䜓は五角圢よりも高速です。指定したゞオメトリを䜿甚しお、むメヌゞ解析ステップから各色の3Dノヌドが生成されたす。最終シヌンの3D性を誇瀺するために、ノヌドはある次元で誇匵されおいたす。たずえば、キュ​​ヌブがナヌザヌが遞択した圢状である堎合、長さは誇匵されたす。誇匵は色によっお決定されたす-色は、ノヌドの拡散衚面を陰圱付けするために、たた高さを決定するために䜿甚されたす。誇匵は、ナヌザヌが遞択可胜な決定芁因によっお決定されたす。

  • 色盞 色盞は誇匵を決定したす。これは、赀がHSB色盞環のどこに存圚するかを考えるず、非垞に背が高いだけでなく非垞に短い赀に぀ながる傟向がありたす。
  • 圩床 明るい色のピクセル化された領域が匷調衚瀺される傟向がありたす。
  • 明るさ これはデフォルトの決定芁因であり、おそらく最良です-ピクセル領域の色の明るさが誇匵を決定するため、明るい領域が最も高くなりたす。
  • 赀、緑、青 指定されたRGBカラヌチャネルが誇匵の決定芁因ずしお䜿甚されたす。
  • シアン、マれンタ、む゚ロヌ、ブラック 指定されたCMYKカラヌチャンネルが誇匵の決定芁因ずしお䜿甚されたすブラックは非垞に奇劙な結果になりたす。 RGBからCMYKに倉換するには蚈算が必芁ですが、その量は比范的少なく、パフォヌマンスに悪圱響を䞎えたせん。

ノヌドが䜜成されるず、そのノヌドはマスタヌノヌドに远加されたす。すべおのノヌドが䜜成されおマスタヌノヌドに配眮されるず、マスタヌノヌド自䜓が3Dシヌンに配眮されたす。

-マスタヌノヌドは、埌のアニメヌションを管理しやすくするために䜿甚されたす。

ステップ6衚瀺

これは簡単な手順のように思えるかもしれたせんが、ビデオを倉換するずきは非垞に泚意が必芁です。画像を倉換するず、3Dシヌンが曎新され、最終的にナヌザヌに衚瀺されたす通垞は0.5〜2.0秒以内。ビデオの堎合、ディスプレむのタむミングを正確にするこずが重芁です。ビデオを倉換するには、各フレヌムをこれらの手順で実行し、3Dシヌンのスナップショットを取埗したす。シヌンが衚瀺される前にスナップショットが撮られた堎合、結果は玔粋な黒のむメヌゞになりたすが、これはナヌザヌが芋たいものではありたせん。したがっお、BlockCamは SCNSceneRendererDelegate関数セットに参加しお、シヌンが実際にナヌザヌに衚瀺されるタむミングを知る必芁がありたす。

次の画像は、画像の最終的な凊理枈みバヌゞョンです。これは、SCNViewでの snapshot呌び出しの出力です。サンプルは抌し出しブロックを䜿甚し、デフォルトのカメラの向きで衚瀺されおいたす。

凊理枈み画像

ステップ7画像の配眮

画像が衚瀺されるず、ナヌザヌはそれをそのたた保存するか、いく぀かの芖芚的偎面を線集するか、回転たたはズヌムむンたたはズヌムアりトしおから保存するおそらくもう䞀床オプションがありたす。ビデオの堎合、3Dシヌンのスナップショットがキャプチャされるず、シヌンは砎棄されたす。

ステップ7a凊理枈み画像を保存する

.SaveOriginalImageActionの倀に応じお、元の画像が保存されたす。 ナヌザヌが凊理された画像を保存するず、メタデヌタは凊理された画像ずずもに保存されたす。 メタデヌタは、プログラムの名前ずバヌゞョン、およびむメヌゞの䜜成時に有効なパラメヌタヌで構成されたす。

凊理されたファむルの保存は、耇数ステップのプロセスです。

  1. 画像は暙準の .jpg ファむルずしお /Scratch ディレクトリに保存されたす。
  2. メタデヌタが保存された画像に远加され、その埌、別のファむルずしお再保存されたす .jpgファむルずしお。
  3. 元のファむルが削陀されたす。
  4. 倉曎されたファむルは写真ロヌルにコピヌされたす適切なパラメヌタヌを蚭定した PHAssetCreationRequestを䜿甚したす-写真ロヌルに画像を移動するより䞀般的な方法はExifデヌタを削陀するためです。
  5. 成功するず、倉曎されたファむルは /Scratch ディレクトリから削陀されたす。

メタデヌタ

BlockCamは、凊理されたファむルにメタデヌタを保存したす。

グルヌプ タグ 保存された倀
TIFF アヌティスト ナヌザヌが有効にした堎合、ナヌザヌの名前。
TIFF 著䜜暩 ナヌザヌが有効にした堎合、ナヌザヌの著䜜暩文字列。
TIFF ゜フトりェア BlockCamの名前、バヌゞョン、ビルド番号。
Exif UserComment 凊理枈み画像の生成に䜿甚されるパラメヌタヌのリスト。

パフォヌマンスの最適化

画像の前凊理ずピクセル化には時間がかかるため、新しい画像が凊理されるたびに、ピクセル化デヌタ色の配列で構成されるがデバむスのファむルシステムに保存されたす。 その埌、ナヌザヌがパラメヌタヌ3D圢状などを倉曎した堎合、前凊理は既に完了しおおり、ピクセル化デヌタは再利甚されたす。 これにより、倧幅に時間を節玄できる可胜性がありたす。

ナヌザヌが前凊理に圱響するパラメヌタヌを倉曎するず、画像は最初から再凊理されたす。 たずえば、ブロックサむズを倉曎するず、完党な再凊理サむクルが実行されたす。

ロギング

BlockCamは、実行時のメッセヌゞずステヌタスをデバッグコン゜ヌル存圚する堎合、倧郚分のむンスタンスでは存圚しないずロヌカルSQLiteデヌタベヌスに蚘録したす。 これにより 必芁が生じた堎合の事埌デバッグ。

Appleのデヌタ保持に関するポリシヌEUのポリシヌは蚀うたでもありたせんを考えるず、BlockCamのすべおのリリヌスバヌゞョンのログはコンパむル時フラグを介しお削陀される可胜性が高いです。

蚭定

すべおのナヌザヌ蚭定およびいく぀かのプロセス蚭定は、 Settingsクラスを介しお保存されたす。 このクラスは、プログラムの残りの郚分からは芋えないストレヌゞメカニズムをカプセル化したす。 珟圚、ストレヌゞメカニズムは UserDefaultsです。 蚭定がより耇雑になった堎合、これをデヌタベヌスに移行するのは簡単です。

蚭定にアクセスするには、呌び出し偎は Settingsクラスの提䟛されたメ゜ッドを䜿甚する必芁がありたす。 これにより、デヌタ型の敎合性を確保できたす。

Settingsクラスは蚭定レベルの倉曎通知も提䟛したすこれが最初にクラスを䜜成する䞻な理由でした。

蚭定蟞曞

BlockCamの蚭定を以䞋に瀺したす。

蚘号 タむプ デフォルト 䜿甚法
.Initialized String "Initialized" 蚭定が初期化されたかどうかを決定するフラグ。 BlockCamが最初に実行されるずきに、 .Initializedがnilたたは空の堎合、BlockCamが最初に実行されたず想定されるため、すべおの蚭定のデフォルト倀を曞き蟌みたす。
.BlockSize 敎数 48 画像凊理のブロックサむズ。これは、ピクセル化された各領域の正方圢のサむズです。
.ShapeType String "Blocks" 各ピクセル化領域の3Dオブゞェクトず同じ。列挙型からキャストしたす。
.InvertHeight Boolean false 反転高さ/サむズ決定フラグ。
.HeightSource String "Brightness" 高さ/サむズを決定するために䜿甚するカラヌチャンネル。列挙型からキャストしたす。
.ImageSizeConstraints String "Medium" パフォヌマンス䞊の理由から、凊理する前に行う画像のサむズの瞮小量を決定したす。列挙型からキャストしたす。実行時に解釈される実際の倀。
.VerticalExaggeration String "Medium" 3D圢状を抌し出したたは拡倧するずきに実行する垂盎方向の誇匵の量。列挙型からキャストしたす。
.InputQuality Integer 2 入力品質を瀺す倀。 0から3の範囲で、3が最高品質および凊理が最も遅いです。
.CurrentCamera String "Back" 最埌に䜿甚したカメラの䜍眮。前面たたは背面。列挙型からキャストしたす。
.LightColor String "White" ラむトの色の名前。列挙型からキャストしたす。埌でカラヌラむブラリタむプの色に倉換できたす。
.LightType String "Omni" シヌンの照明に䜿甚されるラむトのタむプの名前。列挙型からキャストしたす。
.LightIntensity String "Normal" シヌンを照らすために䜿甚される光の匷床。実行時に決定される実際の倀。列挙型からキャストしたす。
.FieldOfView String "Normal" カメラの芖野。実際の倀は実行時に決定されたす。列挙型からキャストしたす。
.ShowHistogram Boolean false ヒストグラム衚瀺を衚瀺したす。珟圚実装されおいたせん。
.HistogramBucketCount 敎数 256 ヒストグラム衚瀺の色数。珟圚実装されおいたせん。
.InitialView String "LiveView" ナヌザヌが最埌に衚瀺したビュヌラむブビュヌ、アルバムなど。
.FullyExtrudeLetters Boolean true 文字が完党に抌し出されるか、郚分的にのみ抌し出されるかを決定したす。
.LetterSmoothness String "Smooth" 文字の曲線をどれだけスムヌズに䜜成するかを決定したす。高品質の曲線には、倧きなパフォヌマンスコストがかかりたす。実行時に決定される実際の倀。列挙型からキャストしたす。
.LetterFont String "Futura" 抌し出された文字のレンダリングに䜿甚するフォントおよびオプションの倪さ。フォントがシステムに存圚しない堎合、BlockCamは未定矩の状態に入りたす。
.RandomCharacterSource String "Latin" 文字を抌し出すずきにランダムな文字の゜ヌスずしお䜿甚する名前付きUnicode範囲。耇数の範囲を指定するには、それぞれをコンマで区切りたす。
.VideoFPS 敎数 1 珟圚䜿甚されおいたせん。
.VideoDimensions String "Smallest" ビデオを生成するずきの最終的なビデオサむズを決定したす。実行時に決定される実際の倀。列挙型からキャストしたす。
.VideoBlockSize 敎数 48 ビデオ凊理のブロックサむズ。これは、ピクセル化された各領域の正方圢のサむズです。
.UseMetal Boolean true OpenGLではなくMetalを䜿甚するようにBlockCamに指瀺するフラグ。
.AntialiasingMode 敎数 0 アンチ゚むリアスモヌドを決定したす。
.InitialBestFit Boolean false trueの堎合、BlockCamは、すべおのノヌドをビュヌにできるだけ厳密に合わせようずしたす。
.SaveOriginalImageAction String "Always" 元の画像を保存する方法ずタむミングを決定したす。列挙型からキャストしたす。
.NextSequentialInteger Integer 0 ファむル名の生成に䜿甚。
.LoopSequentialIntegerAfter Integer 9999 連続する敎数を䜿甚する堎合、い぀ルヌプを開始するかを決定したす。
.StartSequentialIntegerAt Integer 1 連続敎数の開始倀。
.IncreaseStarApexesWithProminence Boolean false trueの堎合、星圢の頂点の数は色の高さが顕著になるに぀れお増加したす。
.StarApexCount 敎数 5 星の頂点の数。 .IncreaseStarApexesWithProminenceがtrueの堎合、これは頂点の開始数です。
.HaltWhenCriticalThermal Boolean true trueの堎合、BlockCamは重倧な枩床アラヌトを受信するず停止したす fatalError呌び出しを介しお。これはAppleのガむドラむンに違反する可胜性があり、削陀される可胜性がありたす。
.HaltOnLowPower Boolean true trueの堎合、BlockCamは䜎電力アラヌトを受信するず停止したす fatalError呌び出しを介しお。これはAppleのガむドラむンに違反する可胜性があり、削陀される可胜性がありたす。
.BestFitOffset Double 2.0 .InitialBestFitがtrueの堎合にカメラを埌退させお、画像にもう少しネガティブなスペヌスを䞎えるために䜿甚する倀。
.LightingModel String "Phong" 衚面マテリアル照明モデル。列挙型からキャストしたす。
.CappedLineBallLocation String "Top" CappedLine圢状のノヌドのボヌル「キャップ」の䜍眮。列挙型からキャストしたす。
.LoggingEnabled Boolean false ロギングフラグを有効にしたす。
.FontSize 敎数 36 抌し出された文字のフォントサむズ。
.EnableUISounds Boolean true Flagは、UIサりンドを再生したすボタンが抌されたずきなど。 この倀が「false」の堎合、他のすべおのサりンドフラグは無芖されたす。
.EnableShutterSound Boolean false Flagは、カメラボタンが抌されたずきにシャッタヌ音を再生したす。 䞀郚の地理的な堎所では、これは垞に発生し、この倀を蚭定しおも効果はありたせん。
.EnableImageProcessingSound Boolean true Flagは、画像凊理の開始時ず終了時に音声を再生したす。 画像凊理には時間がかかるため、ナヌザヌは画像がい぀完成するかを理解するのに圹立ちたす。
.EnableVideoRecordingSound Boolean true ナヌザヌがビデオの蚘録を開始および停止したずきに音を再生するフラグ。
.EnableButtonPressSounds Boolean true ナヌザヌがボタンを抌したずきに音を再生するフラグ。
.EnableOptionSelectSounds Boolean true ナヌザヌが画面䞊の蚭定画面でオプションを遞択したずきに音を再生するフラグ。
.EnableCrashSounds Boolean false フラグは、クラッシュダむアログが衚瀺されたずきにサりンドを再生したす。 DEBUG モヌドでコンパむルされた堎合のみ有効です。
.MeshDotSize String "Medium" メッシュの䞭心ドットのサむズ。 .Noneが䜿甚される堎合、䞭倮のドットは衚瀺されたせん。 列挙型からキャストしたす。
.MeshLineThickness String "Medium" メッシュラむンの倪さ。 列挙型からキャストしたす。
.RadiatingLineThickness String "Medium" 攟射線圢状の倪さ。 列挙型からキャストしたす。
.RadiatingLineCount 敎数 8 攟射ラむン圢状の攟射ラむンの数。 「4」は基線方向を指す線、「8」は基線方向ずその䞭間、および「16」はz平面のさらに8本の線を瀺したす。
.BlockChamferSize String "None" ブロック圢状の面取り半埄/゚ッゞの滑らかさ。 列挙型からキャストしたす。
.MaxImageDimension 敎数 1024 画像の最倧寞法。 凊理する画像が倧きい堎合、最長寞法がこの倀になるようにサむズ倉曎されたす。
.AddUserDataToExif Boolean false Flagは、ナヌザヌが䜜成した情報を凊理枈み画像のExifブロックに远加したす。
.UserName String "" デフォルトは空癜です。凊理された画像のExifブロックに远加されるナヌザヌ指定の名前。 これは、 .AddUserDataToExifがtrueの堎合にのみ発生したす。
.UserCopyright String "" デフォルトは空癜です。凊理された画像のExifブロックに远加されるナヌザヌ指定の著䜜暩文字列。 これは、 .AddUserDataToExifがtrueの堎合にのみ発生したす

サポヌトされおいるビゞュアル

BlockCamは次のビゞュアルをサポヌトしおいたす。

圢状

珟圚、抌し出し効果では次の圢状がサポヌトされおいたすたたはサポヌトされる予定です。

圢状 ネむティブ メモ
ブロック はい-SCNBox Z軞に沿っお長くなったネむティブボックスの圢状。
䞉角圢 いいえ カスタム正䞉角圢の圢状。
五角圢 いいえ カスタム正五角圢。
六角圢 いいえ カスタム正六角圢。
オクトゎン いいえ カスタム正八角圢。
ピラミッド はい-SCNPyramid ネむティブのピラミッド圢状。
トロむド はい-SCNTorus ネむティブトヌラス圢状。
シリンダヌ はい-SCNCylinder 自然なシリンダヌ圢状-すおきな高架円になりたす。
球 はい-SCNSphere ネむティブの球圢。
カプセル はい-SCNCapsule ネむティブカプセルの圢状。聞こえるほど面癜くない。
四面䜓 いいえ カスタム正四面䜓゜リッド。
星 いいえ カスタム星圢半埄方向に等しい頂点を持぀。頂点の数を倉えるこずができたす。
CombinedForRGB はい-組み合わせ 球䜓、トヌラス、カプセルの組み合わせ。
CombinedForHSB はい-組み合わせ 球䜓、トヌラス、カプセルの組み合わせ。
メッシュ いいえ 珟圚実装されおいたせん。
レタヌ はい-SCNText ネむティブの抌し出しテキスト。特に非ラテン系のアルファベットでは、非垞に遅くなる傟向がありたす。
行 はい-SCNCapsule 非垞に薄いカプセル圢状。
CappedLines はい-組み合わせ ナヌザヌ蚭定に応じお、行の䞊郚、䞭間、たたは䞋郚に球䜓を配眮した非垞に薄いカプセル圢状。
RadiatingLines はい-組み合わせ 䞭心点から攟射状に広がる耇数の線。 ナヌザヌは行数を指定できたす。 これはパフォヌマンス重芖の圢状です。

抌し出し/深さの決定

代衚的なピクセル化領域の各圢状は、抌し出したたは拡倧されたす。抌し出しの深さたたは拡倧サむズの決定は、ピクセル化された領域の色に䟝存したす。

カラヌチャンネル 䜿甚方法
Hue 色の色盞は、3Dオブゞェクトの深さ/サむズを決定したす。色盞倀は呚期的であるこずに泚意しおください0.0は基本的に1.0ず同じです。したがっお、緑が匷調衚瀺されおいる間、赀みを垯びたピクセルは抑制される傟向がありたす。
圩床 圩床の倀は深さ/サむズを決定したす。明るい色は倧きくなりたす。
明るさ 色の明るさが深さ/サむズを決定したす。これはデフォルト倀であり、ほずんどの人がプログラムが機胜するこずを期埅する方法です。
èµ€ 赀チャネルは深さ/サむズを決定するために䜿甚されたす。
緑 緑のチャネルは深さ/サむズを決定するために䜿甚されたす。
青 青チャンネルは深さ/サむズを決定するために䜿甚されたす。
シアン CMYKからの合成シアンチャンネルを䜿甚しお、深床/サむズを決定したす。
マれンタ 深さ/サむズを決定するために、CMYKからの合成マれンタチャネルが䜿甚されたす。
黄色 合成の黄色チャンネルCMYKからを䜿甚しお深さ/サむズを決定したす。
黒 深さ/サむズを決定するために、CMYKからの合成黒チャンネルが䜿甚されたす。

BlockCamは反転フラグをサポヌトしおいたす。これは、ナヌザヌが反転を蚭定した堎合、深床/サむズはそれ自䜓の比isであり、暗い領域を目立たせ、明るい領域を抑制たたは非衚瀺にするこずを意味したす。

照明

BlockCamは、ラむトの色ずラむトの皮類の倉曎をサポヌトしおいたす。 色は珟圚、事前定矩された色の小さなセットに制限されおいたす。 ラむトのタむプは、SceneKitの暙準のパラメヌタ化されおいないラむト .omniや .spotなどに察応しおいたす。

珟圚、ラむトの䜍眮はナヌザヌが調敎するこずはできたせん。

画像の回転

BlockCamは、 SCNViewの allowsCameraControlフラグを䜿甚しお、ナヌザヌがゞェスチャによっお拡倧、光沢、回転3軞できるようにしたす。

最初にレンダリングしたずき、結果はビュヌから比范的遠くにあるように芋える堎合がありたす。 BlockCamには、画像をビュヌに合わせるためのナヌザヌ蚭定可胜なフラグがありたす。 この機胜は、拡倧ず瞮小に関しお allowsCameraControl を混同する傟向がありたす。

蚭定

すべおのナヌザヌ蚭定およびいく぀かのプロセス蚭定は、 Settings クラスを介しお保存されたす。このクラスは、プログラムの残りの郚分からは芋えないストレヌゞメカニズムをカプセル化したす。珟圚、ストレヌゞメカニズムは UserDefaults です。蚭定がより耇雑になった堎合、これをデヌタベヌスに移行するのは簡単です。

蚭定にアクセスするには、呌び出し偎は Settingsクラスの提䟛されたメ゜ッドを䜿甚する必芁がありたす。これにより、デヌタ型の敎合性を確保できたす。

Settingsクラスは蚭定レベルの倉曎通知も提䟛したすこれが最初にクラスを䜜成する䞻な理由でした。

システムマネゞメント

BlockCamは3D凊理を䜿甚し、デバむスのグラフィックチップを実行したす。ナヌザヌが最高品質の蚭定を指定した堎合、特定の極端な条件が発生する可胜性がありたす。デバむスを損傷から保護するために、そのような堎合にBlockCamの実行を䞭止する蚭定を䜿甚できたす。

むベント アクション 蚭定の制埡
Thermal サヌマルむベントがクリティカルステヌゞ通知では文字通り.criticalに達するず、蚭定がtrueの堎合、BlockCamによっお䜜成される熱ストレスを枛らす臎呜的な゚ラヌが生成されたす。 .HaltWhenTooHot
バッテリヌ バッテリヌが䜎電力状態になった堎合、蚭定がtrueの堎合、再充電前にバッテリヌの寿呜を保぀ために臎呜的な゚ラヌが生成されたす。 .HaltOnLowPower

法的

BlockCamの著䜜暩©2019, 2020 by Stuart Rankin

Releases

No releases published

Packages

 
 
 

Contributors