def createMailBoxLocal(self, totalCoreCount): msg = [] (inStore, inW, inH, inS) = self.input.getDetails() sliceHeightRound = int(inH) / int(totalCoreCount) (outStore, outW, outH, outS) = self.out.getDetails() for coreNum in range(totalCoreCount): sliceHeight = sliceHeightRound if coreNum == totalCoreCount - 1: sliceHeight = sliceHeight + (int(inH) % int(totalCoreCount)) cmd = graph.VXCommand() currInOffset = coreNum * int(sliceHeightRound * inS) cmd.appendStorage(inStore, currInOffset, 0) currOutOffset = (coreNum * outS) cmd.appendStorage(outStore, currOutOffset, 28) cmd.appendMsgType(16) cmd.appendMbox32le(currInOffset) #src1 cmd.appendMbox32le(0) #src2 ..NA cmd.appendMbox32be(sliceHeight) #ysize cmd.appendMbox32be(inW) #xsize cmd.appendMbox32be(inS) #src1_step cmd.appendMbox32be(0) #src2_step #dst_step is ignored to be aligned with vendor delivery cmd.appendMbox32be(0) #dst_step cmd.appendMbox32le(currOutOffset) #dst cmd.appendMbox32be(0) #pad1.. dont care cmd.appendMbox32be(0) #type cmd.appendMbox32be(0) #scalarVal cmd.appendMbox32be(1) #scalarTypeflag cmd.appendMbox32be(0) #pad[0].. dont care cmd.appendMbox32be(0) #pad[1].. dont care msg = msg + cmd.getData() return msg
def createMailBoxLocal(self, total_cores, img): msg = [] (imStore, w, h, s) = img.getDetails() for core_num in range(total_cores): scale = max(1, min(int((self.width * 1.0 / w) * 256), 65535)) cmd = graph.VXCommand() cmd.appendStorage(self.histogram.getStorage(), 0, 0) cmd.appendStorage(imStore, 0, 4) cmd.appendStorage(self.results.getStorage(), core_num * 46 * 8, 8) cmd.appendHogLut(24, 32) cmd.appendStorage(self.intHog.getStorage(), 0, 36) if core_num == 0: cmd.appendHogSync(self.syncMatStorage, 48, w) else: cmd.appendStorage(self.syncMatStorage, 0, 48) cmd.appendHogRect(self.rect.getStorage(), self.results.getStorage(), core_num * 46 * 8, scale, self.num_rect) cmd.appendMsgType(35) cmd.appendMbox32le(0) #dst/hist cmd.appendMbox32le(0) #src/img cmd.appendMbox32le(0) #result cmd.appendMbox32be((h << 16) | w) #w and h cmd.appendMbox32be(self.histogram.getStride()) cmd.appendMbox32be(s) cmd.appendMbox32le(0) #SQRT Lut cmd.appendMbox32be((total_cores << 16) | core_num) cmd.appendMbox32le(0) #Ped SVM cmd.appendMbox32le(0) #int Hog cmd.appendMbox32be((96 << 16) | 48) #w and h cmd.appendMbox32be(int(self.quality * (1 << 27))) cmd.appendMbox32le(0) #sync cmd.appendMbox32be(0xDBBEB000) #irho msg = msg + cmd.getData() return msg
def createMailBoxLocal(self, total_cores, prev_img, curr_img, level): msg = [] num_points_per_core_round = int(self.pointCount) / int(total_cores) num_key_points_per_core_round = int( self.tmpOld.getWidth() * self.tmpOld.getHeight()) / int(total_cores) (prevStore, prevW, prevH, prevS) = prev_img.getDetails() (currStore, currW, currH, currS) = curr_img.getDetails() (prevPtsStore, prevPtsW, prevPtsH, prevPtsS) = self.old_points.getDetails() (currPtsStore, currPtsW, currPtsH, currPtsS) = self.new_points.getDetails() for core_num in range(total_cores): num_points_per_core = int(num_points_per_core_round) num_key_points_per_core = int(num_key_points_per_core_round) if core_num == total_cores - 1: num_points_per_core = num_points_per_core + ( int(self.pointCount) % int(total_cores)) num_key_points_per_core = num_key_points_per_core + ( int(self.tmpOld.getWidth() * self.tmpOld.getHeight()) % int(total_cores)) cmd = graph.VXCommand() cmd.appendStorage(prevStore, 0, 8) cmd.appendStorage(currStore, 0, 12) offset = int(((core_num * num_points_per_core_round)) * 8) keyOffset = int(((core_num * num_key_points_per_core_round)) * 28) cmd.appendStorage(self.tmpOld.getStorage(), offset, 24) if (level == self.max_level): cmd.appendOptFlowPreProc( prevPtsStore, currPtsStore, keyOffset, self.tmpOld.getStorage(), offset, min(num_key_points_per_core, num_points_per_core)) offset = int(((core_num * num_points_per_core_round)) * 8) cmd.appendStorage(self.tmpNew.getStorage(), offset, 28) if (level == 0): cmd.appendOptFlowPostProc( currPtsStore, prevPtsStore, keyOffset, self.tmpNew.getStorage(), offset, min(num_key_points_per_core, num_points_per_core)) cmd.appendOptFlowAddPoints( currPtsStore, self.new_points_estimates.getStorage(), min(self.new_points_estimates.getMaxCount(), self.new_points.getMaxCount())) cmd.appendMsgType(23) cmd.appendMbox32be(0) #pad0_h cmd.appendMbox32be(self.winsize) cmd.appendMbox32le(0) cmd.appendMbox32le(0) cmd.appendMbox32be(prevS) cmd.appendMbox32be(prevH) cmd.appendMbox32le(0) cmd.appendMbox32le(0) cmd.appendMbox32be(num_points_per_core) cmd.appendMbox32be(0) cmd.appendMbox32be(level) cmd.appendMbox32be(self.max_level) cmd.appendMbox32be(self.epsilon) cmd.appendMbox32be(self.max_count) msg = msg + cmd.getData() return msg
def createMailBoxLocal(self): msg = [] (inStore, inW, inH, inS) = self.input.getDetails() (outStore, outW, outH, outS) = self.output.getDetails() sliceHeight = int(inH) outputImageOffset = 0 inputImageOffset = 0 #need to check input,output for same width,height slice_info = utils.VENDOR_SLICE_FULL_FRAME #integral works only for single core cmd = graph.VXCommand() cmd.appendStorage(outStore, outputImageOffset, 0) cmd.appendStorage(inStore, inputImageOffset, 4) cmd.appendMsgType(utils.VENDOR_MSG_INTEGRAL) cmd.appendMbox32le(outputImageOffset) #dst cmd.appendMbox32le(inputImageOffset) #src cmd.appendMbox32be(sliceHeight) cmd.appendMbox32be(outW) cmd.appendMbox32be(outS) cmd.appendMbox32be(inS) cmd.appendMbox32be(0) #pad dont care cmd.appendMbox32be(slice_info) cmd.appendMbox32be(0) #pad[0]dont care cmd.appendMbox32be(0) #pad[1]dont care cmd.appendMbox32be(0) #pad[2]dont care cmd.appendMbox32be(0) #pad[3]dont care cmd.appendMbox32be(0) #pad[4]dont care cmd.appendMbox32be(0) #pad[5]dont care msg = msg + cmd.getData() return msg
def createMailBox(self,totalCoreCount): msg = [] for i in range(self.getNumJobs()): msg = msg + self.createMailBoxLocal(i) for j in range(1,totalCoreCount): cmd = graph.VXCommand() cmd.appendDummyMsg() msg = msg + cmd.getData() return msg
def createMailBox(self,totalCoreCount): logger = logging.getLogger(__name__) if (totalCoreCount > 1): logger.warning('vxIntegralImageNode: runs in single core only') msg = [] for i in range(self.getNumJobs()): msg = msg + self.createMailBoxLocal() for j in range(1,totalCoreCount): cmd = graph.VXCommand() cmd.appendDummyMsg() msg = msg + cmd.getData() return msg
def createMailBoxLocal(self, total_cores, idx): msg = [] scaleFactor = max(1, min(int((self.factor[idx])*256), 65535)) (resultStore,resW,resH,resStep) = self.results.getDetails() (reSizeStore, width, height, step) = self.resizeImg[idx].getDetails() startPixel = [ 0, 0, 0, 0, 0, 0, 0, 0 ] chunksPerCore = round(self.chunkCnt[idx]/total_cores); if (chunksPerCore is 0): chunksPerCore = 1 if (chunksPerCore != 1): self.maxRslts = total_cores else: self.maxRslts = self.chunkCnt[idx] if (self.maxRslts > total_cores): self.maxRslts = total_cores for cnt in range(self.maxRslts): startPixel[cnt] = cnt * chunksPerCore * FACEDETECT_COL_STEPX_BYTES; chunkStartOffset = startPixel[cnt] if ((cnt + 1) == total_cores): chunkW = width - chunkStartOffset else: chunkW = (chunksPerCore - 1) * FACEDETECT_COL_STEPX_BYTES + FACEDETECT_WINSIZE_X cmd = graph.VXCommand() cmd.appendStorage(resultStore, (self.dstOffset*cnt), 0) cmd.appendStorage(reSizeStore, chunkStartOffset, 4) cmd.appendHaarFrontFaceTable(24) cmd.appendHaarRect(self.rect.getStorage(), resultStore, self.dstOffset*cnt, scaleFactor, self.num_rect, chunkStartOffset ) cmd.appendMsgType(utils.VENDOR_MSG_HAAR) #haar cmd.appendMbox32le(0) #dst/points cmd.appendMbox32le(0) #src/img cmd.appendMbox32be(height) cmd.appendMbox32be(chunkW) cmd.appendMbox32be(resStep) cmd.appendMbox32be(step) cmd.appendMbox32le(0) #haar Tbl cmd.appendMbox32le(0) #norm_fctr cmd.appendMbox32le(0) #pad[0] cmd.appendMbox32le(0) #pad[1] cmd.appendMbox32le(0) #pad[2] cmd.appendMbox32le(0) #pad[3] cmd.appendMbox32le(0) #pad[4] cmd.appendMbox32le(0) #pad[5] msg = msg + cmd.getData() for j in range(self.maxRslts,total_cores,1): cmd = VXCommand() cmd.appendDummyMsg() msg = msg + cmd.getData() return msg
def createMailBoxLocal(self, totalCoreCount, inp, outp): msg = [] (inStore, inW, inH, inS) = inp.getDetails() (outStore, outW, outH, outS) = outp.getDetails() sliceHeightRound = int(outH) / int(totalCoreCount) for coreNum in range(totalCoreCount): sliceHeight = sliceHeightRound if coreNum == totalCoreCount - 1: sliceHeight = sliceHeight + (int(outH) % int(totalCoreCount)) outputImageOffset = (coreNum * int(sliceHeightRound * outS)) inputImageOffset = (coreNum * int(sliceHeightRound * inS)) #need to check input,output for same width,height apart from type if totalCoreCount == 1: slice_info = utils.VENDOR_SLICE_FULL_FRAME elif (totalCoreCount > 1): if coreNum == 0: slice_info = utils.VENDOR_SLICE_TOP_SLICE elif (coreNum < totalCoreCount - 1): slice_info = utils.VENDOR_SLICE_MIDDLE_SLICE else: slice_info = utils.VENDOR_SLICE_BOTTOM_SLICE cmd = graph.VXCommand() cmd.appendStorage(outStore, outputImageOffset, 0) cmd.appendStorage(inStore, inputImageOffset, 4) cmd.appendMsgType(2) #msgIdcvDilateErode cmd.appendMbox32le(outputImageOffset) #dst cmd.appendMbox32le(inputImageOffset) #src1 cmd.appendMbox32be(sliceHeight) cmd.appendMbox32be(outW) cmd.appendMbox32be(outS) cmd.appendMbox32be(inS) for i in range(8): cmd.appendMbox8(self.mask) #mask cmd.appendMbox32be(0) #threshold_val - dont care cmd.appendMbox8(0) #cpad[0] -- dontcare cmd.appendMbox8(0) #cpad[1] - dontcare cmd.appendMbox8(0) #cpad[2] - dontcare cmd.appendMbox8(self.mask_last) #mask_last cmd.appendMbox32be(slice_info) #slice_info cmd.appendMbox32be(self.type) #type.. dilate/erode cmd.appendMbox32be(0) #yoffset.. dontcare cmd.appendMbox32be(self.bitMode) #0 = 8bit mode, 1 = 16bit mode msg = msg + cmd.getData() return msg
def createMailBoxLocal(self, totalCoreCount): msg = [] (inStore, inW, inH, inS) = self.input.getDetails() (outStore, outW, outH, outS) = self.output.getDetails() sliceHeight = int(inH) / int(totalCoreCount) if ((self.input.type == brcm_openvx.VX_DF_IMAGE_U8) and (self.output.type == brcm_openvx.VX_DF_IMAGE_S16)): type = 1 else: type = 0 outW = outW * 2 for coreNum in range(totalCoreCount): if coreNum == totalCoreCount - 1: sliceHeight = sliceHeight + (int(inH) % int(totalCoreCount)) outputImageOffset = (coreNum * int(sliceHeight * outS)) inputImageOffset = (coreNum * int(sliceHeight * inS)) if totalCoreCount == 1: slice_info = utils.VENDOR_SLICE_FULL_FRAME elif (totalCoreCount > 1): if coreNum == 0: slice_info = utils.VENDOR_SLICE_TOP_SLICE elif (coreNum < totalCoreCount - 1): slice_info = utils.VENDOR_SLICE_MIDDLE_SLICE else: slice_info = utils.VENDOR_SLICE_BOTTOM_SLICE cmd = graph.VXCommand() cmd.appendStorage(outStore, outputImageOffset, 0) cmd.appendStorage(inStore, inputImageOffset, 4) cmd.appendMsgType(21) #msgIdcvConvertTo cmd.appendMbox32le(outputImageOffset) #dst cmd.appendMbox32le(inputImageOffset) #src cmd.appendMbox32be(sliceHeight) cmd.appendMbox32be(outW) cmd.appendMbox32be(outS) cmd.appendMbox32be(inS) cmd.appendMbox32be(type) cmd.appendMbox32be(slice_info) cmd.appendMbox32be(0) #pad[0]dont care cmd.appendMbox32be(0) #pad[1]dont care cmd.appendMbox32be(0) #pad[2]dont care cmd.appendMbox32be(0) #pad[3]dont care cmd.appendMbox32be(0) #pad[4]dont care cmd.appendMbox32be(0) #pad[5]dont care msg = msg + cmd.getData() return msg
def createMailBoxLocal(self, totalCoreCount, job): output = job[0] mask = job[1] msg = [] (inStore, inW, inH, inS) = self.input.getDetails() sliceHeightRound = int(inH) / int(totalCoreCount) (outStore, outW, outH, outS) = output.getDetails() for coreNum in range(totalCoreCount): sliceHeight = sliceHeightRound if coreNum == totalCoreCount - 1: sliceHeight = sliceHeight + (int(inH) % int(totalCoreCount)) cmd = graph.VXCommand() currInOffset = (coreNum * int(sliceHeightRound * inS)) cmd.appendStorage(inStore, currInOffset, 4) currOutOffset = (coreNum * int(sliceHeightRound * outS)) cmd.appendStorage(outStore, currOutOffset, 0) cmd.appendMsgType(utils.VENDOR_MSG_SOBEL) cmd.appendMbox32le(currOutOffset) #dst cmd.appendMbox32le(currInOffset) #src cmd.appendMbox32be(sliceHeight) #ysize xsize = inW if self.mode == utils.VENDOR_SOBEL_16bit: xsize = xsize * 2 cmd.appendMbox32be(xsize) #xsize cmd.appendMbox32be(outS) #dst_step cmd.appendMbox32be(inS) #src_step for i in range(8): cmd.appendMboxS8(mask[i]) #mask cmd.appendMbox32be(0) #pad1 cmd.appendMbox8(0) #cpad[0] cmd.appendMbox8(0) #cpad[1] cmd.appendMbox8(0) #cpad[2] cmd.appendMboxS8(mask[8]) #mask_last cmd.appendMbox32be(self.mode) #mode if totalCoreCount > 1: if coreNum == 0: sliceType = utils.VENDOR_SLICE_TOP_SLICE elif coreNum == totalCoreCount - 1: sliceType = utils.VENDOR_SLICE_BOTTOM_SLICE else: sliceType = utils.VENDOR_SLICE_MIDDLE_SLICE else: sliceType = utils.VENDOR_SLICE_FULL_FRAME cmd.appendMbox32be(sliceType) #slice_info cmd.appendMbox32be(0) #pad[0] cmd.appendMbox32be(0) #pad[1] msg = msg + cmd.getData() return msg
def createMailBoxLocal(self,totalCoreCount,scalarType,scalarObj=None): msg = [] (outStore, outW, outH, outS) = self.out.getDetails() sliceHeightRound = int(outH)/int(totalCoreCount) for coreNum in range(totalCoreCount): sliceHeight = sliceHeightRound if coreNum == totalCoreCount - 1: sliceHeight = sliceHeight + (int(outH) % int(totalCoreCount)) cmd = graph.VXCommand() offset = coreNum*int(sliceHeightRound*outS) cmd.appendStorage(outStore, offset, 28) inImage1Step = 0 inImage2Step = 0 #This checks are maintained in sync with vendor delivery if self.in1 is not None: (storage, w, h, s) = self.in1.getDetails() inImage1Step = s offset = (coreNum*int(sliceHeightRound*s)) cmd.appendStorage(storage, offset, 0) if self.in2 is not None: (storage, w, h, s) = self.in2.getDetails() inImage2Step = s offset = (coreNum*int(sliceHeightRound*s)) cmd.appendStorage(storage, offset, 4) scalarValue = 0 if scalarObj is not None: if isinstance(scalarObj,scalar.VXScalar): (scalarName,scalarType,scalarOffset,scalarSize,scalarValue) = scalarObj.getDetails() cmd.appendScalar(scalarName, scalarOffset, 40, graph.WRITE_TYPE_32BE, defn.VX_SCALAR_TYPES[scalarType]) else: scalarValue = scalarObj cmd.appendMsgType(10) cmd.appendMbox32le(0) #src1 cmd.appendMbox32le(0) #src2 cmd.appendMbox32be(sliceHeight) cmd.appendMbox32be(outW * (1 + self.bitMode)) cmd.appendMbox32be(inImage1Step) cmd.appendMbox32be(inImage2Step) cmd.appendMbox32be(outS) cmd.appendMbox32le(0) cmd.appendMbox32be(self.extParam) #extParam cmd.appendMbox32be(self.opcode) #opcode cmd.appendMbox32be(scalarValue) #scalarVal cmd.appendMbox32be(scalarType) #scalarType cmd.appendMbox32be(0) #pad[0] cmd.appendMbox32be(self.bitMode) #bitMode msg = msg + cmd.getData() return msg
def createMailBoxLocal(self, totalCoreCount): msg = [] (inName, inW, inH, inS) = self.input.getDetails() sliceHeightRound = int(inH) / int(totalCoreCount) (outName, outW, outH, outS) = self.output.getDetails() for coreNum in range(totalCoreCount): sliceHeight = sliceHeightRound if coreNum == totalCoreCount - 1: sliceHeight = sliceHeight + (int(inH) % int(totalCoreCount)) cmd = graph.VXCommand() currInOffset = (coreNum * int(sliceHeightRound * inS)) cmd.appendStorage(inName, currInOffset, 4) currOutOffset = (coreNum * int(sliceHeightRound * outS)) cmd.appendStorage(outName, currOutOffset, 0) cmd.appendMsgType(utils.VENDOR_MSG_SMOOTH) cmd.appendMbox32le(currOutOffset) #dst cmd.appendMbox32le(currInOffset) #src cmd.appendMbox32be(sliceHeight) #ysize cmd.appendMbox32be(inW * (self.bitMode + 1)) #inW cmd.appendMbox32be(outS) #dst_step cmd.appendMbox32be(inS) #src_step for mask in self.mask: cmd.appendMbox8(mask) #mask cmd.appendMbox32be(0) #pad1 cmd.appendMbox8(0) #cpad[0] cmd.appendMbox8(0) #cpad[1] cmd.appendMbox8(0) #cpad[2] cmd.appendMbox8(self.maskLast) #mask_last cmd.appendMbox32be(self.smoothType) #mode if totalCoreCount > 1: if coreNum == 0: sliceType = utils.VENDOR_SLICE_TOP_SLICE elif coreNum == totalCoreCount - 1: sliceType = utils.VENDOR_SLICE_BOTTOM_SLICE else: sliceType = utils.VENDOR_SLICE_MIDDLE_SLICE else: sliceType = utils.VENDOR_SLICE_FULL_FRAME cmd.appendMbox32be(sliceType) #slice_info cmd.appendMbox32be(0) #pad[0] cmd.appendMbox32be(0) #pad[1] msg = msg + cmd.getData() return msg
def createMailBoxLocal(self,jobNum): (inStorage, inW, inH, inS) = self.input.getDetails() tempName = 0 tempOffset = self.graph.getTotalTempSize() tempS = 128 # This is to be in sync with vendor delivery (meanName,meanType,meanOffset,meanSize,meanValue) = self.mean.getDetails() cmd = graph.VXCommand() #write src1 cmd.appendStorage(inStorage, 0, 0) #write dst extParam = 0 if jobNum == 0: tempOffset = tempOffset + (meanOffset * 8) cmd.appendStorage(context.VXStorage(tempName, 0, tempOffset), 0, 28) #mean opcode = OPCODE_STAT_SUM #post proc mean cmd.readAvg(tempName,tempOffset,meanName,inW*inH) if jobNum == 1: (stddevName,stddevType,stddevOffset,stddevSize,stddevValue) = self.stddev.getDetails() tempOffset = tempOffset + (stddevOffset * 8) cmd.appendStorage(context.VXStorage(tempName, 0, tempOffset), 0, 28) #stddev opcode = OPCODE_STAT_SUMMEAN #update extParam == pre proc cmd.appendScalar(meanName, meanOffset, 32, graph.WRITE_TYPE_32BE, defn.VX_SCALAR_TYPES[meanType]) #postproc cmd.readStdDev(tempName,tempOffset,stddevName,inW*inH) cmd.appendMsgType(utils.VENDOR_MSG_STAT) cmd.appendMbox32le(0) #src1 cmd.appendMbox32le(0) #src2 cmd.appendMbox32be(inH) cmd.appendMbox32be(inW) cmd.appendMbox32be(inS) cmd.appendMbox32be(0) cmd.appendMbox32be(tempS) cmd.appendMbox32le(tempOffset) cmd.appendMbox32be(extParam) #extParam cmd.appendMbox32be(opcode) #opcode cmd.appendMbox32be(0) #scalarVal cmd.appendMbox32be(1) #scalarType cmd.appendMbox32be(0) #pad[0] cmd.appendMbox32be(0) #pad[1] return cmd.getData()
def createMailBoxLocal(self, input, outH, outF, total_cores): msg = [] (inputStore, inputW, inputH, inputS) = input.getDetails() (outHStore, outHW, outHH, outHS) = outH.getDetails() (outFStore, outFW, outFH, outFS) = outF.getDetails() slice_height_round = int(inputH) / int(total_cores) slice_height_round = slice_height_round - (slice_height_round % 2) for core_num in range(total_cores): slice_height = slice_height_round if core_num == total_cores - 1: slice_height = int(inputH) - ( (total_cores - 1) * slice_height_round) cmd = graph.VXCommand() offset = (core_num * int(slice_height_round * inputS)) cmd.appendStorage(inputStore, offset, 4) offset = (core_num * int(slice_height_round * outHS)) cmd.appendStorage(outHStore, offset, 0) offset = (core_num * int((slice_height_round / 2) * outFS)) cmd.appendStorage(outFStore, offset, 36) cmd.appendMsgType(utils.VENDOR_MSG_LPDOWN) # LPDown cmd.appendMbox32le(0) #dst cmd.appendMbox32le(0) #src cmd.appendMbox32be(slice_height) #src cmd.appendMbox32be(inputW) #src cmd.appendMbox32be(outHS) cmd.appendMbox32be(inputS) cmd.appendMbox32be(0) #pad[0] if total_cores > 1: if core_num == 0: slice = 1 elif core_num == total_cores - 1: slice = 4 else: slice = 2 else: slice = 0 cmd.appendMbox32be(slice) #slice_info cmd.appendMbox32be(0) #pad[1] cmd.appendMbox32le(0) #outF cmd.appendMbox32be(0) #pad[1] cmd.appendMbox32be(outFS) cmd.appendMbox32be(0) #pad[2] cmd.appendMbox32be(0) #pad[3] msg = msg + cmd.getData() return msg
def createMailBoxLocal(self, totalCoreCount): msg = [] (outStore, outW, outH, outS) = self.output.getDetails() (inStore, inW, inH, inS) = self.input.getDetails() sliceHeightRound = int(outH)/int(totalCoreCount) for coreNum in range(totalCoreCount): sliceHeight = sliceHeightRound if coreNum == totalCoreCount - 1: sliceHeight = sliceHeight + (int(outH) % int(totalCoreCount)) outputImageOffset = (coreNum*int(sliceHeightRound*outS)) inputImageOffset = (coreNum*int(sliceHeightRound*inS)) rc = self.thresh.threshVal if rc < 0: rc = 0 if rc > self.max: rc = self.max; self.threshold_val = rc rc = self.thresh.trueVal if rc < 0: rc = 0 if rc > self.max: rc = self.max self.maxVal = rc cmd = graph.VXCommand() cmd.appendStorage(outStore, outputImageOffset, 0) cmd.appendStorage(inStore, inputImageOffset, 4) cmd.appendMsgType(0)#msgIdcvThreshold cmd.appendMbox32le(0) #dst cmd.appendMbox32le(0) #input cmd.appendMbox32be(sliceHeight) cmd.appendMbox32be(outW) cmd.appendMbox32be(outS) cmd.appendMbox32be(inS) cmd.appendMbox32be(self.threshold_val) cmd.appendMbox32be(self.thresh.thresholdType) cmd.appendMbox32be(self.maxVal) cmd.appendMbox32be(self.bitMode)#0 = 8bit mode, 1 = 16bit mode cmd.appendMbox32be(0) cmd.appendMbox32be(0) cmd.appendMbox32be(0) cmd.appendMbox32be(0) msg = msg + cmd.getData() return msg
def createMailBoxLocal(self, totalCoreCount): msg = [] (inStore, inW, inH, inS) = self.input.getDetails() sliceHeightRound = int(inH) / int(totalCoreCount) (outStore, outW, outH, outS) = self.output.getDetails() for coreNum in range(totalCoreCount): sliceHeight = sliceHeightRound if coreNum == totalCoreCount - 1: sliceHeight = sliceHeight + (int(inH) % int(totalCoreCount)) cmd = graph.VXCommand() currInOffset = (coreNum * int(sliceHeightRound * inS)) cmd.appendStorage(inStore, currInOffset, 4) currOutOffset = (coreNum * int(sliceHeightRound * outS)) cmd.appendStorage(outStore, currOutOffset, 0) cmd.appendMsgType(utils.VENDOR_MSG_CANNY) cmd.appendMbox32le(currOutOffset) #dst cmd.appendMbox32le(currInOffset) #src cmd.appendMbox32be(sliceHeight) #ysize cmd.appendMbox32be(inW) #xsize cmd.appendMbox32be(outS) #dst_step cmd.appendMbox32be(inS) #src_step cmd.appendMbox32be(self.threshold.lowerVal) #lowt cmd.appendMbox32be(self.threshold.upperVal) #hight cmd.appendMbox32be(0) #aperture cmd.appendMbox32be(0) #flags if totalCoreCount > 1: if coreNum == 0: sliceType = utils.VENDOR_SLICE_TOP_SLICE elif coreNum == totalCoreCount - 1: sliceType = utils.VENDOR_SLICE_BOTTOM_SLICE else: sliceType = utils.VENDOR_SLICE_MIDDLE_SLICE else: sliceType = utils.VENDOR_SLICE_FULL_FRAME cmd.appendMbox32be(sliceType) #slice_info cmd.appendMbox32be(0) #pad[0] cmd.appendMbox32be(0) #pad[1] cmd.appendMbox32be(0) #pad[2] msg = msg + cmd.getData() return msg
def createMailBox(self, totalCoreCount): msg = [] (outStore, outW, outH, outS) = self.output.getDetails() (inStore, inW, inH, inS) = self.input.getDetails() sliceHeightRound = int(outH) / int(totalCoreCount) for coreNum in range(totalCoreCount): sliceHeight = sliceHeightRound if coreNum == totalCoreCount - 1: sliceHeight = sliceHeight + (int(outH) % int(totalCoreCount)) cmd = graph.VXCommand() offset = coreNum * int(sliceHeightRound * outS) cmd.appendStorage(outStore, offset, 0) offset = self.overlayOffset[coreNum * sliceHeightRound] cmd.appendStorage(inStore, offset, 4) cmd.appendTable(self.tableName, self.tableOffset + 8 * coreNum * sliceHeightRound, 32) cmd.appendTable(self.tableName, self.tableOffset + 8 * outH, 36) cmd.appendMsgType(39) cmd.appendMbox32le(0) #src1 cmd.appendMbox32le(0) #src2 cmd.appendMbox32be(outS) cmd.appendMbox32be(inS) cmd.appendMbox32be(inH) cmd.appendMbox32be(inW) cmd.appendMbox32be(sliceHeight) cmd.appendMbox32be(outS) cmd.appendMbox32le(0) cmd.appendMbox32le(0) cmd.appendMbox32be(0) #pad[0] cmd.appendMbox32be(0) #pad[1] cmd.appendMbox32be(0) #pad[2] cmd.appendMbox32be(0) #pad[3] msg = msg + cmd.getData() return msg
def createMailBoxLocal(self, totalCoreCount): msg = [] (inputStore, inputW, inputH, inputS) = self.input.getDetails() (outputStore, outputW, outputH, outputS) = self.output.getDetails() slice_height_round = int(inputH) / int(totalCoreCount) slice_height_round = slice_height_round - (slice_height_round % 2) for coreNum in range(totalCoreCount): slice_height = slice_height_round if coreNum == totalCoreCount - 1: slice_height = int(inputH) - ( (totalCoreCount - 1) * slice_height_round) cmd = graph.VXCommand() offset = (coreNum * int(slice_height_round * inputS)) cmd.appendStorage(inputStore, offset, 4) offset = (coreNum * int((slice_height_round * 2) * outputS)) cmd.appendStorage(outputStore, offset, 0) cmd.appendMsgType(28) #upsample cmd.appendMbox32le(0) #dst cmd.appendMbox32le(0) #src cmd.appendMbox32be(slice_height) #src cmd.appendMbox32be(inputW) #src cmd.appendMbox32be(outputS) #src cmd.appendMbox32be(inputS) #src #mask0 cmd.appendMbox8(1) cmd.appendMbox8(4) cmd.appendMbox8(6) cmd.appendMbox8(4) cmd.appendMbox8(1) cmd.appendMbox8(4) cmd.appendMbox8(16) cmd.appendMbox8(24) #mask1 cmd.appendMbox8(16) cmd.appendMbox8(4) cmd.appendMbox8(6) cmd.appendMbox8(24) cmd.appendMbox8(36) cmd.appendMbox8(24) cmd.appendMbox8(6) cmd.appendMbox8(4) #mask2 cmd.appendMbox8(16) cmd.appendMbox8(24) cmd.appendMbox8(16) cmd.appendMbox8(4) cmd.appendMbox8(1) cmd.appendMbox8(4) cmd.appendMbox8(6) cmd.appendMbox8(4) if totalCoreCount == 1: slice_info = utils.VENDOR_SLICE_FULL_FRAME elif (totalCoreCount > 1): if coreNum == 0: slice_info = utils.VENDOR_SLICE_TOP_SLICE elif (coreNum < totalCoreCount - 1): slice_info = utils.VENDOR_SLICE_MIDDLE_SLICE else: slice_info = utils.VENDOR_SLICE_BOTTOM_SLICE cmd.appendMbox32be(slice_info) #slice_info #cpad[3] cmd.appendMbox8(0) cmd.appendMbox8(0) cmd.appendMbox8(0) #mmask_last cmd.appendMbox8(1) msg = msg + cmd.getData() return msg
def createMailBoxLocal(self, input, output, total_cores): msg = [] (inputStore, inputW, inputH, inputS) = input.getDetails() (outputStore, outputW, outputH, outputS) = output.getDetails() #print str(inputName)+":Width=" +str(inputW) + " Height="+ str(inputH) + " Stride="+ str(inputS) + " Offset=" + str(inputOffset) #print str(outputName)+":Width=" +str(outputW) + " Height="+ str(outputH) + " Stride="+ str(outputS)+ " Offset=" + str(outputOffset) slice_height_round = int(inputH) / int(total_cores) slice_height_round = slice_height_round - (slice_height_round % 2) for core_num in range(total_cores): slice_height = slice_height_round if core_num == total_cores - 1: slice_height = int(inputH) - ( (total_cores - 1) * slice_height_round) cmd = graph.VXCommand() offset = (core_num * int(slice_height_round * inputS)) cmd.appendStorage(inputStore, offset, 4) offset = (core_num * int((slice_height_round / 2) * outputS)) cmd.appendStorage(outputStore, offset, 0) cmd.appendMsgType(4) cmd.appendMbox32le(0) #dst cmd.appendMbox32le(0) #src cmd.appendMbox32be(slice_height) #src cmd.appendMbox32be(inputW) #src cmd.appendMbox32be(outputS) #src cmd.appendMbox32be(inputS) #src #mask0 cmd.appendMbox8(1) cmd.appendMbox8(4) cmd.appendMbox8(6) cmd.appendMbox8(4) cmd.appendMbox8(1) cmd.appendMbox8(4) cmd.appendMbox8(16) cmd.appendMbox8(24) #mask1 cmd.appendMbox8(16) cmd.appendMbox8(4) cmd.appendMbox8(6) cmd.appendMbox8(24) cmd.appendMbox8(36) cmd.appendMbox8(24) cmd.appendMbox8(6) cmd.appendMbox8(4) #mask2 cmd.appendMbox8(16) cmd.appendMbox8(24) cmd.appendMbox8(16) cmd.appendMbox8(4) cmd.appendMbox8(1) cmd.appendMbox8(4) cmd.appendMbox8(6) cmd.appendMbox8(4) if total_cores > 1: if core_num == 0: slice = 1 elif core_num == total_cores - 1: slice = 4 else: slice = 2 else: slice = 0 cmd.appendMbox32be(slice) #slice_info #cpad[3] cmd.appendMbox8(0) cmd.appendMbox8(0) cmd.appendMbox8(0) #mmask_last cmd.appendMbox8(1) msg = msg + cmd.getData() return msg
def createMailBoxLocal(self,totalCoreCount): msg = [] (inStorage, inW, inH, inS) = self.input.getDetails() (outStorage, outW, outH, outS) = self.output.getDetails() sliceHeightRound = int(inH)/int(totalCoreCount) sliceHtRnddiv4 = sliceHeightRound & ~3 diff = sliceHeightRound - sliceHtRnddiv4 clrType = self.code >> 4 convType = self.code & 0xF for coreNum in range(totalCoreCount): if ((self.input.type != brcm_openvx.VX_DF_IMAGE_UYVY) and (self.input.type != brcm_openvx.VX_DF_IMAGE_YUYV)): #msgIdcvCvtYUYV2RGB sliceHeight = sliceHtRnddiv4 else: sliceHeight = sliceHeightRound diff = 0 if coreNum == totalCoreCount - 1: sliceHeight = sliceHeight + (int(inH) % int(totalCoreCount)) + (diff * int(totalCoreCount)) outputYImageOffset = (coreNum*int(sliceHeight*outS)) inputImageOffset = (coreNum*int(sliceHeight*inS)) #need to check input,output for same width,height if (self.output.type == brcm_openvx.VX_DF_IMAGE_IYUV): outputUImageOffset = (outH*outS) + ((coreNum * sliceHeight * outS)/4) outputVImageOffset = (outH*outS) + ((coreNum * sliceHeight * outS)/4) + ((outH*outS)/4) else: outputUImageOffset = 0 outputVImageOffset = 0 if (self.input.type == brcm_openvx.VX_DF_IMAGE_IYUV): inputUImageOffset = (inH*inS) + ((coreNum * sliceHeight * inS)/4) inputVImageOffset = (inH*inS) + ((coreNum * sliceHeight * inS)/4) + ((inH*inS)/4) if ((self.input.type == brcm_openvx.VX_DF_IMAGE_NV12) or (self.input.type == brcm_openvx.VX_DF_IMAGE_NV21)): inputUImageOffset = (inH*inS) + ((coreNum * sliceHeight * inS)/2) inputVImageOffset = inputUImageOffset cmd = graph.VXCommand() cmd.appendStorage(outStorage, outputYImageOffset, 0) if (self.output.type == brcm_openvx.VX_DF_IMAGE_IYUV): cmd.appendStorage(outStorage, outputUImageOffset, 32) cmd.appendStorage(outStorage, outputVImageOffset, 36) cmd.appendStorage(inStorage, inputImageOffset, 4) if ((self.input.type == brcm_openvx.VX_DF_IMAGE_NV12) or (self.input.type == brcm_openvx.VX_DF_IMAGE_NV21) or (self.input.type == brcm_openvx.VX_DF_IMAGE_IYUV)): cmd.appendStorage(inStorage, inputUImageOffset, 8) cmd.appendStorage(inStorage, inputVImageOffset, 12) if ((self.input.type == brcm_openvx.VX_DF_IMAGE_NV12) or (self.input.type == brcm_openvx.VX_DF_IMAGE_NV21) or (self.input.type == brcm_openvx.VX_DF_IMAGE_IYUV)): cmd.appendMsgType(17) #msgIdcvRGB2YUV elif ((self.input.type == brcm_openvx.VX_DF_IMAGE_UYVY) or (self.input.type == brcm_openvx.VX_DF_IMAGE_YUYV)): #msgIdcvCvtYUYV2RGB cmd.appendMsgType(36) else: cmd.appendMsgType(29) #msgIdcvRGB2YUV cmd.appendMbox32le(outputYImageOffset) #dst cmd.appendMbox32le(inputImageOffset) #src1 if ((self.input.type == brcm_openvx.VX_DF_IMAGE_NV12) or (self.input.type == brcm_openvx.VX_DF_IMAGE_NV21) or (self.input.type == brcm_openvx.VX_DF_IMAGE_IYUV)): cmd.appendMbox32le(inputUImageOffset) #src_u if IYUV cmd.appendMbox32le(inputVImageOffset) #src_v if IYUV cmd.appendMbox32be(sliceHeight) cmd.appendMbox32be(outW) cmd.appendMbox32be(outS) cmd.appendMbox32be(inS) cmd.appendMbox32be(convType) cmd.appendMbox32be(clrType) if ((self.input.type != brcm_openvx.VX_DF_IMAGE_NV12) and (self.input.type != brcm_openvx.VX_DF_IMAGE_NV21) and (self.input.type != brcm_openvx.VX_DF_IMAGE_IYUV)): cmd.appendMbox32le(outputUImageOffset) #dst_u if IYUV, pad otherwise cmd.appendMbox32le(outputVImageOffset) #dst_v if IYUV, pad otherwise cmd.appendMbox32be(0) #pad[0]dont care cmd.appendMbox32be(0) #pad[1]dont care cmd.appendMbox32be(0) #pad[2]dont care cmd.appendMbox32be(0) #pad[3]dont care msg = msg + cmd.getData() return msg