I am trying to analyze a photo at the same time using the background stream from GCD. Here is the code I wrote:
dispatch_async(dispatch_get_global_queue(Int(QOS_CLASS_UTILITY.value), 0)) {
for (var i = 0; i < 8; i++)
{
let color = self.photoAnalyzer.analyzeColors(imageStrips[i])
colorList.append(color)
}
}
To clarify the names of variables, here are their descriptions:
photoAnalyzeris an instance of class I, called Analyzerthat contains all the image processing methods.
analyzeColorsis a method within a class Analyzerthat does most of the analysis and returns a string with the dominant color of the passed image
imageStripsis an array of UIImageparts of the original image
colorListis an array of strings that stores the return values of the method analyzeColorfor each part of the image.
, for imageList. imageStrips , , .
. , , GitHub.
EDIT 8 .
dispatch_apply(8, imageQueue) { numStrips -> Void in
let color = self.photoAnalyzer.analyzeColors(imageStrips[numStrips])
colorList.append(color)
}
, 8, , .