def __init__(self): AlgorithmProvider.__init__(self) self.alglist = [SumLines(), PointsInPolygon(), PointsInPolygonWeighted(), PointsInPolygonUnique(), BasicStatisticsStrings(), BasicStatisticsNumbers(), NearestNeighbourAnalysis(), MeanCoords(), LinesIntersection(), UniqueValues(), PointDistance(), ReprojectLayer(), ExportGeometryInfo(), Centroids(), Delaunay(), VoronoiPolygons(), SimplifyGeometries(), DensifyGeometries(), DensifyGeometriesInterval(), MultipartToSingleparts(), SinglePartsToMultiparts(), PolygonsToLines(), LinesToPolygons(), ExtractNodes(), Eliminate(), ConvexHull(), FixedDistanceBuffer(), VariableDistanceBuffer(), Dissolve(), Difference(), Intersection(), Union(), Clip(), ExtentFromLayer(), RandomSelection(), RandomSelectionWithinSubsets(), SelectByLocation(), RandomExtract(), RandomExtractWithinSubsets(), ExtractByLocation(), SpatialJoin(), RegularPoints(), SymetricalDifference(), VectorSplit(), VectorGrid(), DeleteColumn(), DeleteDuplicateGeometries(), TextToFloat(), ExtractByAttribute(), SelectByAttribute(), Grid(), Gridify(), HubDistance(), HubLines(), Merge(), GeometryConvert(), AddTableField(), FieldsCalculator(), SaveSelectedFeatures(), JoinAttributes(), AutoincrementalField(), Explode(), FieldsPyculator(), EquivalentNumField(), PointsLayerFromTable(), StatisticsByCategories(), ConcaveHull(), Polygonize(), RasterLayerStatistics(), PointsDisplacement(), ZonalStatistics(), PointsFromPolygons(), PointsFromLines(), RandomPointsExtent(), RandomPointsLayer(), RandomPointsPolygonsFixed(), RandomPointsPolygonsVariable(), RandomPointsAlongLines(), PointsToPaths(), PostGISExecuteSQL(), ImportIntoPostGIS(), SetVectorStyle(), SetRasterStyle(), SelectByExpression(), HypsometricCurves(), # ------ raster ------ # CreateConstantRaster(), # ------ graphics ------ # VectorLayerHistogram(), VectorLayerScatterplot(), # RasterLayerHistogram(), MeanAndStdDevPlot(), # BarPlot(), PolarPlot() ] folder = os.path.join(os.path.dirname(__file__), 'scripts') scripts = ScriptUtils.loadFromFolder(folder) for script in scripts: script.allowEdit = False self.alglist.extend(scripts) for alg in self.alglist: alg._icon = self._icon
def execute(arg1, arg2): # if both args are 0, the result will be -128 otherwise it is the Difference # The idea is that the args treat 0 as NaN so we treat -128 as NaN # Byte data and NaN don't mix any better than this. return where(logical_and(arg1 == 0, arg2 == 0), int8(-128), Difference(arg1, arg2))
def main(threshold, Video, Map): s = time.time() images = [] counter = 0 pos = [] y = [] d = 1 current = os.getcwd() warnings.filterwarnings("ignore") Map1 = Map h1, w1 = Map.shape[:2] img1 = cv2.cvtColor(Map, cv2.COLOR_BGR2GRAY) while True: ret, frame = Video.read() if ret: if counter % 10 == 0: images.append(frame) counter = counter + 1 else: break for loop in range(0, len(images) + 1, 1): try: d = loop start = time.time() orig_image = images[loop] orig_gray = cv2.cvtColor(orig_image, cv2.COLOR_BGR2GRAY) extracted_img, y_cord = img_ex(img1, orig_gray) transformed_img, theta = transform(orig_gray, extracted_img) Diff = Difference(transformed_img, orig_gray, threshold) Result_img, Map, x_map, y_map = Draw(Diff, transformed_img, orig_image, Map, extracted_img, y_cord, theta) if (np.shape(Result_img) != (0, )): filename = current + "/Result_Images/difference_img_%d.jpg" % d cv2.imwrite(filename, Result_img) end = time.time() t = end - start print('Time taken by Image %d:' % d, t) print(' ') '''position = x_map, y_map, theta, d if not os.path.isfile('points.txt'): file = open("points.txt", 'w') else: file = open("points.txt", 'a') file.write(str(position[0])) file.write(',') file.write(str(position[1])) file.write(',') file.write(str(position[2])) file.write(',') file.write(str(position[3])) file.write('\n') file.close()''' else: end = time.time() t = end - start print('Time taken by Image %d:' % d, t) print(' ') except: print('Skipped') filename = current + "/Result_Images/Map.jpg" cv2.imwrite(filename, Map1) print('Total Time:', (time.time() - s))
def subtract(blank, tool): from Difference import Difference return Difference(blank, tool)
def main(imagePaths, Map): s = time.time() images = [] counter = 0 d = 1 for imagePath in imagePaths: image = cv2.imread(imagePath) images.append(image) counter = counter + 1 Map1 = Map img1 = cv2.cvtColor(Map, cv2.COLOR_BGR2GRAY) h, w = Map.shape[:2] for loop in range(0, counter, 1): try: start = time.time() image2 = images[loop] img2 = cv2.cvtColor(image2, cv2.COLOR_BGR2GRAY) extracted_img, y = img_ex(img1, img2, 0) transformed_img, angle = transform(img2, extracted_img, y) filename = "C:\\Users\\ubaid\\AppData\\Local\\Programs\\Python\\Python37\\CodesandImages\\FYPFinalCode\\Result_Images\\extracted&transformed_img_%d.jpg" % d cv2.imwrite(filename, transformed_img) Diff = Difference(transformed_img, img2) Resultant_img, Resultant_img1, Map1 = Draw(Diff, transformed_img, image2, Map1, angle) if (np.shape(Resultant_img) != (0, ) or np.shape(Resultant_img1) != (0, )): filename = "C:\\Users\\ubaid\\AppData\\Local\\Programs\\Python\\Python37\\CodesandImages\\FYPFinalCode\\Result_Images\\difference_img_%d.jpg" % d cv2.imwrite(filename, Resultant_img) filename = "C:\\Users\\ubaid\\AppData\\Local\\Programs\\Python\\Python37\\CodesandImages\\FYPFinalCode\\Result_Images\\difference_orig_img_%d.jpg" % d cv2.imwrite(filename, Resultant_img1) cv2.imwrite( "C:\\Users\\ubaid\\AppData\\Local\\Programs\\Python\\Python37\\CodesandImages\\FYPFinalCode\\Result_Images\\Difference_on_Map.jpg", Map1) end = time.time() t = end - start print('Time taken by Image %d:' % d, t) d = d + 1 else: end = time.time() t = end - start print('Time taken by Image %d:' % d, t) d = d + 1 except: try: image2 = images[loop] img2 = cv2.cvtColor(image2, cv2.COLOR_BGR2GRAY) extracted_img, y = img_ex(img1, img2, 1) transformed_img, angle = transform(img2, extracted_img, y) filename = "C:\\Users\\ubaid\\AppData\\Local\\Programs\\Python\\Python37\\CodesandImages\\FYPFinalCode\\Result_Images\\extracted&transformed_img_%d.jpg" % d cv2.imwrite(filename, transformed_img) Diff = Difference(transformed_img, img2) Resultant_img, Resultant_img1, Map1 = Draw( Diff, transformed_img, image2, Map1, angle) if (np.shape(Resultant_img) != (0, ) or np.shape(Resultant_img1) != (0, )): filename = "C:\\Users\\ubaid\\AppData\\Local\\Programs\\Python\\Python37\\CodesandImages\\FYPFinalCode\\Result_Images\\difference_img_%d.jpg" % d cv2.imwrite(filename, Resultant_img) filename = "C:\\Users\\ubaid\\AppData\\Local\\Programs\\Python\\Python37\\CodesandImages\\FYPFinalCode\\Result_Images\\difference_orig_img_%d.jpg" % d cv2.imwrite(filename, Resultant_img1) cv2.imwrite( "C:\\Users\\ubaid\\AppData\\Local\\Programs\\Python\\Python37\\CodesandImages\\FYPFinalCode\\Result_Images\\Difference_on_Map.jpg", Map1) end = time.time() t = end - start print('Time taken by Image %d:' % d, t) d = d + 1 else: end = time.time() t = end - start print('Time taken by Image %d:' % d, t) d = d + 1 except: print('Skipped') print('Total Time:', (time.time() - s)) return
def __init__(self): AlgorithmProvider.__init__(self) self._icon = QIcon(os.path.join(pluginPath, 'images', 'qgis.png')) self.alglist = [ SumLines(), PointsInPolygon(), PointsInPolygonWeighted(), PointsInPolygonUnique(), BasicStatisticsStrings(), BasicStatisticsNumbers(), NearestNeighbourAnalysis(), MeanCoords(), LinesIntersection(), UniqueValues(), PointDistance(), ReprojectLayer(), ExportGeometryInfo(), Centroids(), Delaunay(), VoronoiPolygons(), SimplifyGeometries(), DensifyGeometries(), DensifyGeometriesInterval(), MultipartToSingleparts(), SinglePartsToMultiparts(), PolygonsToLines(), LinesToPolygons(), ExtractNodes(), Eliminate(), ConvexHull(), FixedDistanceBuffer(), VariableDistanceBuffer(), Dissolve(), Difference(), Intersection(), Union(), Clip(), ExtentFromLayer(), RandomSelection(), RandomSelectionWithinSubsets(), SelectByLocation(), RandomExtract(), DeleteHoles(), RandomExtractWithinSubsets(), ExtractByLocation(), SpatialJoin(), RegularPoints(), SymmetricalDifference(), VectorSplit(), VectorGrid(), DeleteColumn(), DeleteDuplicateGeometries(), TextToFloat(), ExtractByAttribute(), SelectByAttribute(), Grid(), Gridify(), HubDistance(), HubLines(), Merge(), GeometryConvert(), AddTableField(), FieldsCalculator(), SaveSelectedFeatures(), JoinAttributes(), AutoincrementalField(), Explode(), FieldsPyculator(), EquivalentNumField(), PointsLayerFromTable(), StatisticsByCategories(), ConcaveHull(), RasterLayerStatistics(), PointsDisplacement(), ZonalStatistics(), PointsFromPolygons(), PointsFromLines(), RandomPointsExtent(), RandomPointsLayer(), RandomPointsPolygonsFixed(), RandomPointsPolygonsVariable(), RandomPointsAlongLines(), PointsToPaths(), PostGISExecuteSQL(), ImportIntoPostGIS(), SetVectorStyle(), SetRasterStyle(), SelectByExpression(), HypsometricCurves(), SplitLinesWithLines(), CreateConstantRaster(), FieldsMapper(), SelectByAttributeSum(), Datasources2Vrt(), CheckValidity(), OrientedMinimumBoundingBox(), Smooth(), ReverseLineDirection() ] if hasMatplotlib: from VectorLayerHistogram import VectorLayerHistogram from RasterLayerHistogram import RasterLayerHistogram from VectorLayerScatterplot import VectorLayerScatterplot from MeanAndStdDevPlot import MeanAndStdDevPlot from BarPlot import BarPlot from PolarPlot import PolarPlot self.alglist.extend([ VectorLayerHistogram(), RasterLayerHistogram(), VectorLayerScatterplot(), MeanAndStdDevPlot(), BarPlot(), PolarPlot(), ]) if hasShapely: from Polygonize import Polygonize self.alglist.extend([Polygonize()]) if QGis.QGIS_VERSION_INT >= 21400: from ExecuteSQL import ExecuteSQL self.alglist.extend([ExecuteSQL()]) folder = os.path.join(os.path.dirname(__file__), 'scripts') scripts = ScriptUtils.loadFromFolder(folder) for script in scripts: script.allowEdit = False self.alglist.extend(scripts) for alg in self.alglist: alg._icon = self._icon
def main(Video, Map): s = time.time() images = [] counter = 0 d = 1 old_d = 7340 while True: ret, frame = Video.read() if ret: if counter % 10 == 0: images.append(frame) counter = counter + 1 else: break Map1 = Map img1 = cv2.cvtColor(Map, cv2.COLOR_BGR2GRAY) h, w = Map.shape[:2] for loop in range(0, counter, 1): try: start = time.time() image2 = images[loop] img2 = cv2.cvtColor(image2, cv2.COLOR_BGR2GRAY) extracted_img, y = img_ex(img1, img2) try: transformed_img, angle = transform(img2, extracted_img, y) except: print('Old Patch:', old_d) transformed_img, angle = transform(img2, extracted_img, old_d) y = old_d filename = "B:\\Users\\ubaid\\AppData\\Local\\Programs\\Python\\Python37\\CodesandImages\\FYPFinalCode\\Result_Images\\extracted&transformed_img_%d.jpg" % d cv2.imwrite(filename, transformed_img) Diff = Difference(transformed_img, img2) Resultant_img, Resultant_img1, Map1 = Draw(Diff, transformed_img, image2, Map1, angle) if (np.shape(Resultant_img) != (0, ) or np.shape(Resultant_img1) != (0, )): filename = "B:\\Users\\ubaid\\AppData\\Local\\Programs\\Python\\Python37\\CodesandImages\\FYPFinalCode\\Result_Images\\difference_img_%d.jpg" % d cv2.imwrite(filename, Resultant_img) filename = "B:\\Users\\ubaid\\AppData\\Local\\Programs\\Python\\Python37\\CodesandImages\\FYPFinalCode\\Result_Images\\difference_orig_img_%d.jpg" % d cv2.imwrite(filename, Resultant_img1) cv2.imwrite( "B:\\Users\\ubaid\\AppData\\Local\\Programs\\Python\\Python37\\CodesandImages\\FYPFinalCode\\Result_Images\\Difference_on_Map.jpg", Map1) end = time.time() t = end - start print('Time taken by Image %d:' % d, t) d = d + 1 old_d = y else: end = time.time() t = end - start print('Time taken by Image %d:' % d, t) d = d + 1 except: print('Skipped') print('Total Time:', (time.time() - s)) return