text:
# Opencv Rect Intersection

 Rectangle Intersection Testing Algorithm. If A and B each specify one rectangle, the output area is a scalar. !) (See: wxPyWiki:wx. I think it is the key that simplify the project making the life easier. Everything inside rectangle is unknown. dat -vec samples. 需要在图片中把特定的点来标注出来，看了一下cv::circle()函数，先上代码： #include. Let’s go ahead and get started. org OpenCV typically assumes that the top and left boundary of the rectangle are inclusive, while the right and bottom boundaries are not. 2012-12-01. width Width of the rectangle Most OpenCV functions support 1-4 channels. 먼저 1), 내가 그레이 스케일으로 이미지를 변환, 색상의 계약을 높이고 마지막으로 "깨끗. template Rect_ union operator will return Rect(0,0,0,0) when two Rects have only border or point overlap, I think better to keep the overlap info, meaning may return a Rect who's width or/and height may be zero when there is only border or point overlap. And it is a more time-consuming task if you don't know how to do. OpenCV will get the minAreaRect and see it only as a rectangle which rotated from the horizontal (upto 90 degrees). A primitive OpenCV data type is one of unsigned char, bool, signed char, unsigned short, signed short, int, float, double or a tuple of values of one of these types, where all the values in the tuple have the same type. It works to some extend that, few squares are detected, especially the dark ones. OpenCV 3 Tutorial image & video processing Installing on Ubuntu 13 Mat(rix) object (Image Container) Creating Mat objects The core : Image - load, convert, and save Smoothing Filters A - Average, Gaussian Smoothing Filters B - Median, Bilateral OpenCV 3 image and video processing with Python OpenCV 3 with Python Image - OpenCV BGR : Matplotlib RGB. height) return Rect(left, top, right - left, bottom - top) ==演算子では、オーバーロードされたequalsメソッドを使用できます。. A and B can also be matrices, where each row is a position vector. 08: OpenCV를 활용한 이미지 유사도 비교 방법 (Feature Matching) (8) 2017. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58. The boundaries of the shapes can be rendered with antialiasing (implemented only for 8-bit images for now). If the lines should meet, intersect in the space, they would get stuck, maybe the intersection point would move along the lines to allow continuation of the floating of the lines. In this post we have discussed a new approach. Before we discuss solution, let us define notion of orientation. Opencv Code To Extract The Region Of Interest Codes and Scripts Downloads Free. Kd-trees gird implementation 2d tree Range search for 2d tree Nearest Neighbour seach Kd tree 4. Let us break the term down into its two parts — Convex and Hull. Fortunately, OpenCV provides another function that directly implements these operations as shown below. Find the intersection of a line with a plane is a draft programming task. Note that a rectangle can be represented by two coordinates, top left and bottom right. It should now work with OpenCV 2. OpenCV will get the minAreaRect and see it only as a rectangle which rotated from the horizontal (upto 90 degrees). OpenCV-Python Tutorials OpenCV introduces a new set of tutorials which will guide you through various functions available in OpenCV-Python. 2つのRectangleが重なるか判定するコードを紹介します。 概要 Rectangle同士が重なっているかを判定するには、RectangleクラスのIntersectsWith()メソッドを利用すると簡単です。 プログラム UI 下図のUIを作成します。フォームにLabelを一つ配置します。 コード. For example to describe a RGB 24 image pixel the following type can be used:. start_point: It is the starting coordinates of rectangle. A short tutorial on how to detect circles in python using OpenCV. The algorithm reads in the image and converts it using OpenCV s cvtColor() function from RGB to HSV color space. MorphologyEx. cv_next_around_org : cv_next_around_dst : cv_prev_around_org : cv_prev_around_dst : cv_next_around_left : cv_next_around_right : cv_prev_around_left : cv_prev_around. @param hist_1 @param hist_2 @param method the comparison method. A Rect can be created from a combination of left, top, width, and height values. I hope could this * helps someone. Problem: Given a set of N line segments(2*N points), you need to find all intersections between these line segments. Before we discuss solution, let us define notion of orientation. split(img) # get b,g,r rgb_img = cv2. Template Matching is a method for searching and finding the location of a template image in a larger image. This is a good chunk of code, let's break it down line by line. A few months ago I wrote an OpenCV version of the pose estimation algorithm found in the paper Robust Pose Estimation from a Planar Target (2006) by Gerald Schweighofer and Axel Pinz using their Matlab code from the link in the paper. We will briefly explain the algorithm and then follow up with C++ and Python code implementation using OpenCV. OpenCVには線分や四角（長方形、正方形）、円、楕円、円弧、矢印、マーカー、文字など、様々な図形を描画する関数が用意されている。物体を検出した位置を図示したりする際などに便利。次の画像のように図形を描画できる。サンプルコードは最後に示す。はじめに図形描画関数における引数. This is a default interpretation of Rect_::x and Rect_::y in OpenCV. The above works pretty well, but there’s a newer way to approach this problem using the browser’s Intersection Observer API. Y on the top and bottom edges. Rect (x, y, width, height, A rectangle representing the intersection between rect1 and rect2 if it exists, else None. X on the left and right edges, and by the value of point. Paste this code into a form and call the ShowRectangleUnion method when handling the form's Paint event, passing e as PaintEventArgs. If the rectangles do not intersect the returned gtk. point contact // 9 - partial intersection. SubplotParams control the default spacing of the subplots. 1d Range Search 1d range search implementation by BST 2. But edge B, although it is above minVal and is in same region as that of edge C,. Template class for 2D rectangles, described by the following parameters: (rectangle intersection) rect = rect1 | rect2 (minimum area rectangle containing rect2 and rect3) rect &= rect1,. template T& generalized_intersect(T1& a, const T2& b). Make a list file of both (positives. To calculate the center of gravity of a triangle, start by drawing a line from the midpoint of any 1 of the sides to the opposite vertex to create a median. c# - the - opencv largest inscribed rectangle. Standard Module rect This module contains useful operations on rectangles. void rectangle (int left, int top, int right, int bottom); To create a rectangle, you have to pass the. NASA Astrophysics Data System (ADS) Williams, E. opencv 6 --cv2. Thick lines are drawn with rounding endings. Selective Search starts by over-segmenting the image based on intensity of the pixels using a graph. Today, we are going to leverage contour properties to actually label and identify shapes in an image, just like in the figure at the top of this post. minLineLength - Minimum length of line. You could try shapely. I try to write a function that would return the coordinates of the two intersection points of the line segment and the rectangle. 0) (0) 2013. So if you are working with OpenCV, I believe this will save your time. The basic steps of the algorithm are: Choose an orientation for the rectangle. The allocated buffers must be freed with cv::fastFree(). These “include” directories will typically be named something like C:/program files/opencv/ cv/include,† …/opencv/cxcore/include, …/opencv/ml/include, and …/opencv/otherlibs/ highgui. remap: Applies a generic geometrical transformation to an image. Find a minimal bounding rectangle for a polygon in C# Posted on July 29, 2014 by RodStephens This program assumes that its Points array contains the points in a convex polygon in counterclockwise order. These can be shapes that you build out of custom geometry or shapes that you load from an external file, such as an SVG. I hope could this * helps someone. c++ - rectangle - paper detection opencv python Detecting a sheet of paper / Square Detection; What you need is a quadrangle instead of a rotated rectangle. Open Source Computer Vision Library. Those are two functions (intersection and union) that have already been provided by rectangle class in OpenCV. The 8-connected or 4-connected Bresenham algorithm is used for simple line segments. height) return Rect(left, top, right - left, bottom - top) ==演算子では、オーバーロードされたequalsメソッドを使用できます。. A and B can also be matrices, where each row is a position vector. thanks 100% (1 rating) Fromopencv doc: rect = rect1 & rect2 (rectangle intersection) rect = rect1 | rect2 (minimum area rectangle containing rect2 and rect3 ) It also supports equality comparision (==) rect == rect1 So it view the full answer. Making statements based on opinion; back them up with references or personal experience. The function fillConvexPoly draws a filled convex polygon. It mainly focuses on image processing, video capture and analysis including features like face detection and object detection. To get an estimate of the dimensions of the rectangle we can use a bounding rectangle of the corners. 6K views 11 comments 0 points Most recent by ashleyjamesbrown September 2017 Kinect. With a threshold of 0 it doesn't do any grouping at all, and with a threshold of 1 is only returns rectangles that were the result of at least 2 rectangles. Formally, the convex hull may be defined as the intersection of all convex sets containing X or as the set of all convex combinations of points in X. $mkdir build PhD:~/opencv$ cd build/ PhD:~/opencv/build$cmake. NET (C#, VB, C++ and more) Crossplatform. Note You have to define SIMD_OPENCV_ENABLE in order to use this functionality. 27 [영상처리] openCV Edge 검출 알고리즘2 (0) 2017. It is easy to visualize that the given two rectangles can not be intersect if one of the following conditions is true. asarray (unified)[np. The Hough transform is fairly robust to noise and occlusions, so it could be useful here. HoughLinesP(). Rectクラスに用意されたintersect()メソッドで交差判定が可能です。. It has 2500+ optimized algorithms—a comprehensive set of both classic and state-of-the-art computer vision and machine learning algorithms. A and B can also be matrices, where each row is a position vector. Object detection is a task in computer vision and image processing that deals with detecting objects in images or videos. Next, we’re going to create a function detecting a face and drawing a rectangle around it. Trying to install OpenCV and getting a program to run took me 3 hours going through various tutorials and guides. Here we will learn to apply the following function on an image using Python OpenCV: Bitwise Operations and Masking, Convolution & Blurring, Sharpening - Reversing the image blurs, Thresholding (Binarization), Dilation, Erosion, Opening/Closing, Edge detection and Image gradients,. Before we discuss solution, let us define notion of orientation. Although edge C is below maxVal, it is connected to edge A, so that also considered as valid edge and we get that full curve. 1 Windows10 Word アフィン変換 アンシャープマスキング カメラ カラー光切断法. Virtually every loop over an image ROI in OpenCV (where ROI is specified by Rect_ ) is implemented as: for ( int y = roi. width) bottom = max(A. 3。 2012 Apr : OpenCV 2. Deprecated: Function create_function() is deprecated in /www/wwwroot/dm. Parameters [in] p - specified point. This entry was posted in Image Processing and tagged bitwise and, bitwise operations, cv2. theta: The resolution of the parameter in radians. This guide is mainly focused on OpenCV 3. Rectangle width and height. public static opencv_core. opencv库函数学习：Rect函数 时间:2019-03-05 本文章向大家介绍opencv库函数学习：Rect函数，主要包括opencv库函数学习：Rect函数使用实例、应用技巧、基本知识点总结和需要注意事项，具有一定的参考价值，需要的朋友可以参考一下。. Intersect those lines and you have the 4 most likely corner points. The function finds the four vertices of a rotated rectangle. However, it wont let me. Post navigation ← Monitoring Training in Keras: Callbacks Floating Point Arithmetic Limitations in Python →. We will briefly explain the algorithm and then follow up with C++ and Python code implementation using OpenCV. I'm using OpenCV and want to group together rectangles that have significant overlap. Here is the code and example input image. Determines whether CRect is equal to the given rectangle. where (child_status == 0)] return unified # discard everythink except what's inside the contours. This is a default interpretation of Rect_::x and Rect_::y in OpenCV. template Rect_ union operator will return Rect(0,0,0,0) when two Rects have only border or point overlap, I think better to keep the overlap info, meaning may return a Rect who's width or/and height may be zero when there is only border or point overlap. Largest rectangle in a polygon An approximation algorithm for finding the largest rectangle inside a non-convex polygon. The H and S channels are not used. c++ - rectangle - paper detection opencv python Detecting a sheet of paper / Square Detection; What you need is a quadrangle instead of a rotated rectangle. CvArr image, com. X on the left and right edges, and by the value of point. The following code example demonstrates the Intersect, IsEmpty and the IntersectsWith members. If it's not, click on the thumbnail to select it. com Recent Posts. How can I find these points of intersection between the rectangle and the contour outline. The support package also contains graphics processing unit (GPU) support. So, the data layout in Mat is fully compatible with CvMat, IplImage, and CvMatND types from OpenCV 1. ; lines: A vector to store the coordinates of the start and end of the line. The following code example demonstrates the Intersect, IsEmpty and the IntersectsWith members. In this tutorial, we demonstrate how to perform Hough Line and Circle detection using Emgu CV, as well as using the Contour class to detect Triangles and Rectangles in the image. Only the V (Value) channel is passed to OpenCV s threshold() function using a threshold of 200 and THRESH_BINARY flag resulting in a high contrast black and white image. OpenCV - Hough Line Transform - You can detect the shape of a given image by applying the Hough Transform technique using the method HoughLines() of the Imgproc class. def rotated_rect_iou (rectA, rectB): """Computes the ratio of the intersection area of the input rectangles to the (sum of rectangle areas - intersection area) Used with the NMS function:param rectA: a polygon (rectangle) described by its verticies:type rectA: list:param rectB: a polygon (rectangle) describe by it verticies:type rectB: list:returns: The ratio of the intersection area / (sum of. OpenCV lies at the intersection of these topics, providing a comprehensive open-source library for classic as well as state-of-the-art Computer Vision and Machine Learning algorithms. Open Source Computer Vision Library. Alasannya komunitas pengembang OpenCV yang sangat aktif, free, serta memuat banyak sekali algoritma-algoritma image processing & computer vision, seperti face detection, edge detection, SIFT, stereo vision, konvolusi menggunakan filter window, dan masih banyak lainnya.$\endgroup$- N. 11 [OpenCV] OpenCV 1. OpenCV is now C++11 library and requires C++11-compliant compiler. With OpenCV, extracting features and its descriptors via the ORB detector is as easy as:. OpenCV provides 2 models for this face detector. Here's a simple Processing draw () method that draws an rectangle following the mouse. The figure module provides the top-level Artist, the Figure, which contains all the plot elements. This is a default interpretation of Rect_::x and Rect_::y in OpenCV. Quadrilateral Shape Finding Algorithm (3) I want to detect and and return the point where they intersect, easy to do mathematically. This guide is mainly focused on OpenCV 3. r1: Bottom Right coordinate of first rectangle. 0 released。 2010 Dec : OpenCV 2. You could try shapely. tileInfo is not supported. drawContours(mRgba, contours, -1, CONTOUR_COLOR, -1);<>Core. Intersection over Union for object detection. boundingRect(). Instead of get_insersec_region, I would call this method __and__. All the functions include the parameter color that uses an RGB value (that may be constructed with CV_RGB or the Scalar_ constructor ) for color images and brightness for. I think it is the key that simplify the project making the life easier. Make a list file of both (positives. If A and B each specify one rectangle, the output area is a scalar. The coordinates are represented as tuples of two values i. Daniel 08 Jul 2014. More void boxPoints (RotatedRect box, OutputArray points) Finds the four vertices of a. It uses cv:floodFill with 4 connected neighbours. Hi I am trying to access the openc cv webcam face detecting script (FACEWEB) in another script attached to a gameobject. You can use your own made up values. OpenCV provides 2 models for this face detector. FAST( (Mat)image, (object)threshold [, (bool)nonmax_supression=True]) -> object : Argument 'keypoints': C/C++ type: ::std::vector< cv::KeyPoint > &. I only put in the ones I needed immediately. geometry import Point from shapely. def find_box_using_opencv(image, min_width, min_height, max_width, max_height, debug): #find a slide/box in an image (should only pass images that contain a single slide) lower_bound_pixel = 0 #values used in colour thresholding upper_bound_pixel = 5 opencv_image = numpy. Those are two functions (intersection and union) that have already been provided by rectangle class in OpenCV. 0) (0) 2013. Help and Feedback You did not find what you were looking for? C - Tracking objects using histogram data in OpenCV. Although solving printed sudoku puzzle via a vision-based application by itself is not a valuable thing and may be seen as an easy problem, you will gain a lot of knowledge through solving this problem and it could take a time to produce a robust solution. The edge A is above the maxVal, so considered as sure-edge. 0 2009 Oct : Version 2. The axial component of kinetic energy of particles slightly exceeds 100 keV and the rotational component of the ions energy is a bit greater than 1 MeV. 11 [OpenCV] FPS 표시하기 (0) 2013. Superset and Jupyter notebooks on AWS as Service November 22, 2019; Installing Apache Superset into CentOS 7 with Python 3. Introduction. So if you are working with OpenCV, I believe this will save your time. This is a default interpretation of Rect_::x and Rect_::y in OpenCV. In order to have mutual conversion with OpenCV rectangle you have to define macro SIMD_OPENCV_ENABLE:. For the needed algebra bit I will be using numpy. This essentially implies and is implied by the statement : the area of the respective triangle > 1 2 the area of the rectangle (as commented by Ben Voigt) as △APD = 1 2AD ⋅ PAD. very helpfull. OpenCV и Java. @param pt2 Vertex of the rectangle opposite to pt1. 이전페이지 1 ··· 2306 2307 2308 2309 2310 2311 2312 2313 2314 ··· 6734. If no intersection exists, return None. I have searched the API Documentation, but couldn't find a useful resource. The Element. The algorithm uses the OpenCV and SVMLight library. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. Net wrapper for OpenCV. cv::Point2f start, end; double length = cv::norm(end - start); 선 교차점을 계산하기 위해 코드 조각이 필요한 경우 여기에 있습니다. Open Source Computer Vision Library. The one exception is in the GUI and GUILayout classes, where Y increases downwards. If A and B each specify one rectangle, the output area is a scalar. start_point: It is the starting coordinates of rectangle. Press J to jump to the feed. The result graph of edge detection is then outlined using OpenCV's built-in findContours function, which is described in detail. Though, in your algorithms you may count x and y from the bottom-left corner. boundingRect(). area = rectint(A,B) returns the area of intersection of the rectangles specified by position vectors A and B. 2012-12-01. c# - the - opencv largest inscribed rectangle. DNN: Face Detection. tileInfo is not supported. Just take min and max x and y values. The following example shows how to use the Intersect(Rect) method to find the intersection of two rectangles and store the result as a rectangle. In Euclidean geometry, the intersection of a line and a line can be the empty set, a point, or a line. Recommend：java - OpenCV Android - How to draw a circle/rectangle around contours. For example, the method Rect_::contains returns true if \[x \leq pt. It uses a prune-and-search technique to find the largest rectangle with two corners on the polygon and a tentative prune-and-search to find the largest rectangle with three corners on the polygon. In the previous chapter, we printed the area of a rectangle by making an object of the Rectangle class. Before moving to the concept of array of objects, let's first see an example of. (사각형의 교차부분 intersection 을 구함) rect = rect1 | rect2 (rect1 과 rect2 를 동시에 포함하는 가장 작은 영역의 사각형을 구함) rect &= rect1,. How can I find these points of intersection between the rectangle and the contour outline. Hi I am trying to access the openc cv webcam face detecting script (FACEWEB) in another script attached to a gameobject. opencv ROI ROI选取 主窗口设置 使用设置 ROI选择 设置窗口位置 获取窗口 获取-窗口 窗口置顶并选中 与父窗口 窗口使用 窗口 窗口 窗口 窗口 窗口 窗口 窗口 窗口 窗口 cdockablepane窗口设置 opencv rect用法 OpenCV Rect用法 opencv python 设置显示窗口 opencv3 roi 滑动窗口 opencv cv2 窗口位置 idea service窗口设置 QT设置. Array extracted from m corresponding to the subvolume that is the intersection of the ranges given by ranges[0]-ranges[ndim-1] Matrix Expressions: Algebra and cv::Mat One of the capabilities enabled by the move to C++ in version 2. Pre-requisite: Line Sweep Algorithms Line intersection problem is a problem solved using line sweep technique. but when I check the points of contours 0 and 5, they seem to run along the edge twice, for example contour 0 starts at the top edge, runs down to the left and back up to the top, along the edge. It provides a Go language interface to the latest version of OpenCV. Hi, I’m new to the forum. Rotated rectangle intersection #1539. py , and we’ll get to work. Rects can also be created from python objects that are already a Rect or have an attribute named "rect". The one we will be using was developed at the OpenCV Lab and it is called ORB (Oriented FAST and Rotated BRIEF). If eyes are recognized, I classify them as opened or narrowed. MorphologyEx. 1- Point and line 2- Point and plane 3- Point and rectangle 4- Point and circle 5- Line and rectangle 6- Line and circle 7- Line and line. The intersection of three planes is either a point, a line, or there is no intersection (any two of the planes are parallel). [영상처리] openCV 히스토그램 (0) 2017. add_argument("-i", "--image", help = "path to the image file. This function is useful to draw the rectangle. I have a rectangle and a line segment inside the rectangle, and the line can be extended on both sides. 5 years since groundbreaking 3. 0, 机器学习,Keras. 之前的几个系列,我们全面的介绍了Cesium的地形内容,详见: Cesium原理篇:1最长的一帧之渲染调度 Cesium原. c# - the - opencv largest inscribed rectangle. union (list) -- function of module rect. This is the rectangle around the element we want to check. OpenCV - Overview. I know the coordinates of the rectangle's four vertices as well as the line's two vertices. Rectangle that is the intersection of this rectangle and the gtk. How can I find these points of intersection between the rectangle and the contour outline. now, to find out, if 2 Rects overlap, just check the area of the intersection: bool intersects = ((A & B). the Intel Image Processing Library processes the area of intersection between the. If the dimensions of that rectangle are under our wanted area, we ignore the polygon. buffer(1), Point(1,1). Are there basic geometric helper functions for intersection/distance calculations. Email This BlogThis! To draw these shapes in Matlab, different ways could be used to achieve this. Given , and , find the maximum width (area) such that the rectangle lies inside the polygon. ArgumentParser() ap. contour_area: computes the contour area. The meaning of that formula is really quite simple. rectangle: Draws a simple, thick, or filled up-right rectangle. I have a rectangle and a line segment inside the rectangle, and the line can be extended on both sides. Also the mask in OpenCV is 8-bit, whereas in IPL it is 1-bit. Overlay Points On Image Python. Primitive PShapes. but when I check the points of contours 0 and 5, they seem to run along the edge twice, for example contour 0 starts at the top edge, runs down to the left and back up to the top, along the edge. INTERSECT_NONE No intersection. Apply this filtersin this specific order has to effect to release all the contours and. Lines 12-13: Iterate through the corners of the faces detected and draw a rectangle in that pattern. py , and we'll get to work. Each pixel is processed in O(1. Обработка изображений и компьютерное зрение | Николай Прохоренок | download | B–OK. (Normally first few stages will contain very less number of features). lines out of an entire image matrix of edge pixels and zeros into the much simpler problem of discovering lines which intersect multiple edge pixels at once. September 25, 2012 No Comments algorithms, delphi, geometry, math. The boundaries of the shapes can be rendered with antialiasing (implemented only for 8-bit images for now). 08 [openCV] Mat 초기화 (0) 2013. The coordinates are represented as tuples of two values i. Shruow says: 2017-09-11 at 17:28. If A and B each specify one rectangle, the output area is a scalar. You can use your own made up values. [OpenCV] OpenCV 1. With a threshold of 0 it doesn't do any grouping at all, and with a threshold of 1 is only returns rectangles that were the result of at least 2 rectangles. 27 [영상처리] openCV 이미지 기본 연산 (0) 2017. If a window fails the first stage, discard it. Although solving printed sudoku puzzle via a vision-based application by itself is not a valuable thing and may be seen as an easy problem, you will gain a lot of knowledge through solving this problem and it could take a time to produce a robust solution. Intersect(Rect, Rect) Returns the intersection of the specified rectangles. Finding Shapes in Images using Python and OpenCV. \brief Calculates contour bounding rectangle (update=1) or just retrieves pre-calculated rectangle (update=0) static void cvBoxPoints ( CvBox2D box, CvPoint2D32f pt). Back to project page android-opencv-template. theta: The resolution of the parameter in radians. This is a good chunk of code, let's break it down line by line. h file in your program. You might see some extra mouse events, such as mouse-exited and then mouse-entered. The best use case of OpenCV DNN is performing real-time object detection on a Raspberry Pi. OpenCV provides 2 models for this face detector. opencv: Combines two rotation-and-shift transformations: C M T: cv. Opencv Code To Extract The Region Of Interest Codes and Scripts Downloads Free. width) bottom = max(A. It is used in a wide variety of real-world applications, including video. 画像の読み込みと表示、保存 OpenCVを使って画像処理をしようにも、まず対象の画像が読み込めないと何もできないそして、いろいろやっていった結果の画像を見れるといいなというわけでさらにいろいろやった結果を出力できたらなおいいというわけで、今回は全てやる 方法 まずcv2. So instead I quickly wrote my own version using existing OpenCV calls. The Hough Line Transform is a transform used to detect straight lines. The article is describing the possibility of using visual systems for mobile robot navigation. X on the left and right edges, and by the value of point. empty if the intersection of the rectangles is empty. since we expect the four lines passing through the four piece corners to form a rectangle, I grouped together lines with the same orientation in order to prune lines that do not belong to this group. Intersecting rectangle when bottom-left and top-right corners of two rectangles are given Given coordinates of 4 points, bottom-left and top-right corners of two rectangles. Rectangle will have all attributes set to 0. Connected-component labeling. Cesium原理篇：5最长的一帧之影像. The returned value is a DOMRect object. The following example shows how to use the Intersect(Rect) method to find the intersection of two rectangles and store the result as a rectangle. The dokill argument is a bool. As far as I know, it is included in version 3 of opencv, and has to be installed. Determines whether CRect is empty. I applied the common method (which comes with OpenCV samples), ie find contours in all color planes, approximate it and check for number of elements=4. In C++, instead of using this function, you can directly use box. Open Source Computer Vision // A vertex of the triangle lies on an edge of the rectangle so handleNested can be false and an intersection is still found. 终于到了有实际应用的功能了，有2张图片，里面各有一个人脸，我的目的是比较这两个人脸的相似度，这里用到了facedetect的功能，还有图像转换，图像剪切，以及直方图的比较。. 直方图均衡化的本质是改变图像的灰度分布，或者说改变图像直方图灰度分布，通过累计灰度级别与相关的数学变换公式，来改变原有的图像直方图灰度分布，然后用改变之后的灰度值重建图像，从而达到调整亮度和对比度的目的。. 0 ( or above ) installed with opencv_contrib. Moves CRect by the specified offsets. This tutorial will show us how to run deep learning models, with face detection and face recognition models pipeline. thickness - Thickness of lines that make up the rectangle. // Finds the intersection of two lines, or returns false. Y on the top and bottom edges. hit_enter_to_continue → None¶ Asks the user to hit enter to continue and pauses until they do so. The function fillConvexPoly draws a filled convex polygon. Rotated rectangle intersection #1539. It allows you to select a rectangle in an image, crop the rectangular region and finally display the cropped image. Parameters [in] p - specified point. making their intersection too far from the real corner. 在对opencv进行应用中，我们常会应用到rect之间的关系，可以采用如下方法来实现： bool rectA_intersect_rectB(cv::Rect rectA, cv::Rect rectB) 如果rectA与rectB相交，则返回true，这里的相交没有包含的概念，如果要用到包含则可根据下面代码进行修改 bool rectA_intersect_rectB(cv::Rect rect. opencv_core opencv_imgproc opencv_highgui opencv_ml opencv_video opencv_features2d opencv_calib3d opencv_objdetect opencv_contrib opencv_legacy opencv_ﬂann If you don’t know where your libraries are (or you are just psychotic and want to make sure the path is ﬁne), type in Terminal: pkg-config --libs opencv. The inner shapes have an "outer" and "inner" contour, as is expected. You can add intersect = __and__ if you also want the expressiveness of overlap = r1. INTERSECT_PARTIAL There is a partial intersection. If you see them grayed out, check to make sure a white highlight border is appearing around the Shape layer's vector mask thumbnail. Following is the syntax of this method. jpg') b,g,r = cv2. Line Segment Intersection Sweep-line algorithm 3. Closed nghiaho12 wants to merge 29 commits into opencv: master from nghiaho12: rotatedRectangleIntersection +788 // In no event shall the OpenCV Foundation or contributors be liable for any direct, // indirect, incidental, special, exemplary, or consequential damages. If the flag consider_touch is true rectangles that abut are considered to intersect. Simple Lane Detection with OpenCV. Coordinates of the top-left corner. It has 2500+ optimized algorithms—a comprehensive set of both classic and state-of-the-art computer vision and machine learning algorithms. This way you don't need any special code to handle e. The function used is cv2. Next, locate the four resulting line intersections to detect the corners. start_point: It is the starting coordinates of rectangle. If you are familiar with OpenCV. The 8-connected or 4-connected Bresenham algorithm is used for simple line segments. OpenCV API에는 라인 교차를 계산하는 함수가 없지만 거리는 다음과 같습니다. The described intersection criteria was chosen over intersection over union to avoid a corner case when small rectangle inside of a big one have small intersection score. That is, if A is n-by-4 and B is m-by-4, then area is an n-by-m matrix where area(i,j) is the intersection area of the rectangles specified by the ith row of A and the jth row of B. opencv_createsamples -info positives. Everything inside rectangle is unknown. You need to build our own machine learning model to do this task. remap: Applies a generic geometrical transformation to an image. If A and B each specify one rectangle, the output area is a scalar. OpenCV는 어파인 변환 행렬을 구하는 함수와 어파인 변환 행렬을 이용하여 실제 영상을 어파인 변환하는 함수를 모두 제공한다. Line 3: Load the classifier from file. OpenCV and Python versions: This example will run on Python 2. area = rectint(A,B) returns the area of intersection of the rectangles specified by position vectors A and B. If you wish to build systems that are smarter, faster, sophisticated, and more practical by combining the power of Computer Vision, Machine Learning, and Deep. r1: Bottom Right coordinate of first rectangle. In the remainder of this blog post I’ll explain what the Intersection over Union evaluation metric is and why we use it. Rectangle that is the intersection of this rectangle and the gtk. In this tutorial, we are going to see some more image manipulations using Python OpenCV. Rects can also be created from python objects that are already a Rect or have an attribute named "rect". (사각형의 교차부분 intersection 을 구함) rect = rect1 | rect2 (rect1 과 rect2 를 동시에 포함하는 가장 작은 영역의 사각형을 구함) rect &= rect1,. This essentially implies and is implied by the statement : the area of the respective triangle > 1 2 the area of the rectangle (as commented by Ben Voigt) as △APD = 1 2AD ⋅ PAD. The template class DataType is descriptive class for OpenCV primitive data types and other types that comply with the following definition. This library include many useful function for computer vision, such as object-detection. Sets to the rectangle results of the intersection of the rectangle and specified point. Return Value: The intersection of this rectangle with the given rectangle, or an empty rectangle if the two do not intersect. the flow of the white line would be red starting from the intersection point. The article is describing the possibility of using visual systems for mobile robot navigation. 画像の読み込みと表示、保存 OpenCVを使って画像処理をしようにも、まず対象の画像が読み込めないと何もできないそして、いろいろやっていった結果の画像を見れるといいなというわけでさらにいろいろやった結果を出力できたらなおいいというわけで、今回は全てやる 方法 まずcv2. You might try using HoughLines to detect the four sides of the square. A Convex object is one with no interior angles greater than 180 degrees. その6 Rectクラスによる矩形の交差判定 2Dのゲームを作る際にはよくキャラクター同士の当たり判定を矩形の交差で判定しますが、Androidアプリを作成する際にはandroid. The paper describing the algorithm also proves that the provided solution is optimal and a lower complexity sequential algorithm cannot exist. That is, similarly to calcHist , at each location (x, y) the function collects the values from the selected channels in the input images and finds the corresponding histogram bin. Hi I am trying to access the openc cv webcam face detecting script (FACEWEB) in another script attached to a gameobject. The support package also contains graphics processing unit (GPU) support. "Instead of applying all the 6000 features on a window, group the features into different stages of classifiers and apply one-by-one. class opencv_wrapper. php on line 143 Deprecated: Function create_function() is deprecated in. Creates a new Rectangle structure on the base of OpenCV rectangle. org Overall Objective: Create Regions of Interest (ROIs) in order to then examine them for objects such as person, dog, vehicle utilizing the Java bindings Approach: BackgroundSubtraction -> FindContours -> downselect to Region of Interest (smallest encompassing rectangle around contours of an object) that is then sent to be. The intersection of three planes is either a point, a line, or there is no intersection (any two of the planes are parallel). We will briefly explain the algorithm and then follow up with C++ and Python code implementation using OpenCV. The 8-connected or 4-connected Bresenham algorithm is used for simple line segments. My project converts the contours of the result of an edge detection to svg, to be used as path information later. Before we discuss solution, let us define notion of orientation. @param thickness Thickness of lines that make up. 0 2009 Oct : Version 2. For every line compute the intersection of the two line segments (if they do not intersect ignore the point) The final step is extract each rectangle from the image. def returnHistogramComparison(self, hist_1, hist_2, method='intersection'): """Return the comparison value of two histograms. If one of the perpendicular distances is greater than the respective length, then P(x, y) is outside the rectangle. OpenCV-Python Tutorials OpenCV introduces a new set of tutorials which will guide you through various functions available in OpenCV-Python. Rect myRectangle = new Rect(); // The Location property specifies the coordinates of the upper left-hand // corner of the rectangle. Given , and , find the maximum width (area) such that the rectangle lies inside the polygon. The axial component of kinetic energy of particles slightly exceeds 100 keV and the rotational component of the ions energy is a bit greater than 1 MeV. OpenCV-Python is a library of Python bindings designed to solve computer vision problems. I think it is the key that simplify the project making the life easier. Pointer circle_storage, int method, double dp, double min_dist, double param1, double param2, int min_radius, int max_radius). Five binary morphological transforms ε Erosion, shrinki. A short tutorial on how to detect circles in python using OpenCV. OpenCV - Overview. OpenCV typically assumes that the top and left boundary of the rectangle are inclusive, while the right and bottom boundaries are not. I think all of the references to box in this function should be references to rect. This will draw the rectangle in these form as shown above. So area of the bounding rectangle won't be minimum. Rectangle width and height. 11 [OpenCV] OpenCV 1. * Actually, it works with an array of Rect, performing, every cicle, an * intersection test with area of difference with the rect of interests * (this array is callad "sa", stands for SizedArea). How to merge overlapping rectangle using opencv java. I'm very new to OpenCV / Emgu CV and am looking for some direction. This function takes the following arguments: edges: Output of the edge detector. getContours();Imgproc. 11 [OpenCV] 2개의 라인에서 교점 찾기(Calculate Intersection between Lines) (0) 2013. Wrapper class for the OpenCV Affine Transformation algorithm. The class is used to specify a row or a column span in a matrix ( Mat) and for many other purposes. 如果把地球比做一个人,地形就相当于这个人的骨骼,而影像就相当于这个人的外表了. 2 works fine with the source code of this tutorial. NASA Astrophysics Data System (ADS) Williams, E. and Kittler, J. ops import cascaded_union from itertools import combinations circles = [ Point(0,0). and Galambos, C. The following code example demonstrates the Intersect, IsEmpty and the IntersectsWith members. The RETR_EXTERNAL parameter is used in the practical application, only the outline of the exterior is extracted. from - rectangle detection using hough transform opencv python Detecting lines and shapes in OpenCV using Python (2) I've been playing around with OpenCV (cv2) and detecting lines and shapes. jpg"); Mat temp=imread("logo. The returned value is a DOMRect object. (private FACEWEB scriptAccess). Rectangle or a 4-tuple containing the position and size of a rectangle. The following examples are illustrated in GUI space, where (0,0) represents the top-left corner and Y increases downwards. OpenCV provides 2 models for this face detector. public static opencv_core. IOU stands for Intersection over union. Write your own function to use plot (), or use rectangle () or use patch (). CRect::operator LPCRECT Converts a CRect to an LPCRECT. So instead I quickly wrote my own version using existing OpenCV calls. and Kittler, J. Harris corner detector and. Coordinates of the top-left corner. Rectangle width and height. Note A position vector is a four-element vector [x,y,width,height] , where the point defined by x and y specifies one corner of the rectangle, and width and height. l2: Top Left coordinate of second rectangle. OpenCV center of contour Figure 1: An example image containing a set of shapes that we are going to compute the center of the contour for. if your object is rotated more than (-)90 degrees, next edge of the rectangle becomes the leading edge and is used to calculate the angle from the horizontal (between -0 to -90). Also, here is an interactive demo showing how the Hough transform works (I thought it was cool at least :). Although edge C is below maxVal, it is connected to edge A, so that also considered as valid edge and we get that full curve. Release the mouse button. This tutorial will show us how to run deep learning models, with face detection and face recognition models pipeline. 30 [OpenCV] Mat 접근 방법(How to access pixel in Mat) (0) 2013. opencv ROI ROI选取 主窗口设置 使用设置 ROI选择 设置窗口位置 获取窗口 获取-窗口 窗口置顶并选中 与父窗口 窗口使用 窗口 窗口 窗口 窗口 窗口 窗口 窗口 窗口 窗口 cdockablepane窗口设置 opencv rect用法 OpenCV Rect用法 opencv python 设置显示窗口 opencv3 roi 滑动窗口 opencv cv2 窗口位置 idea service窗口设置 QT设置. Deprecated: Function create_function() is deprecated in /www/wwwroot/dm. "Instead of applying all the 6000 features on a window, group the features into different stages of classifiers and apply one-by-one. This is a default interpretation of Rect_::x and Rect_::y in OpenCV. Determines whether CRect is empty. Just follow. Looking for faster alternative to Hough transform for detecting a rectangle Anyone know of a faster alternative to a hough transform for detecting a shape (rectangle) in an image ? I'm trying to find the location in an image of a rectangle that can be rotated around all three axes. So instead I quickly wrote my own version using existing OpenCV calls. 0 버전용 간단 사용법 (How To Use OpenCV 2. The model was trained using images available from the web, but the source is not disclosed. 1- Point and line 2- Point and plane 3- Point and rectangle 4- Point and circle 5- Line and rectangle 6- Line and circle 7- Line and line. If the order of the vertices of the polygon is given, we present a randomized algorithm that computes an inscribed rectangle with area at least (1 − ϵ) times the optimum with probability t in time O (1 ϵ log n) for any constant t < 1. 1d Range Search Goal: intersections of geometric. Lightning is of interest in the domain of climate change for several reasons: (1) thunderstorms are extreme forms of moist convection, and lightning flash rate is a sensitive measure of that extremity, (2) thunderstorms are deep conduits for delivering water substance from the boundary layer to the upper. Don't know if this is faster than checking the vertices. First algorithm searches for clusters: two rectangle detections are placed in the same cluster if the intersection score between them is larger then intersection_score_threshold. Face detector based on SSD framework (Single Shot MultiBox Detector), using a reduced ResNet-10 model. import numpy as np import cv2 # Create a black image img = np. Here we will learn to apply the following function on an image using Python OpenCV: Bitwise Operations and Masking, Convolution & Blurring, Sharpening - Reversing the image blurs, Thresholding (Binarization), Dilation, Erosion, Opening/Closing, Edge detection and Image gradients,. OpenCV - Distance Transformation - The distance transform operator generally takes binary images as inputs. This example should be used with a Windows Form. Now, let’s discuss how to implement these using OpenCV-Python. I applied the common method (which comes with OpenCV samples), ie find contours in all color planes, approximate it and check for number of elements=4. So how can we draw it? This is the big question. Finds out if there is any intersection between two rotated rectangles. When specifying a CRect, you must be careful to construct it so that it is normalized — in other words, such that the value of the left coordinate is less than the right and the top is less than the bottom. It is also compatible with the majority of dense array types from the standard toolkits and SDKs, such as Numpy (ndarray), Win32 (independent device bitmaps), and others, that is, with any array that uses *steps* (or *strides*) to compute the. You can use your own made up values. • Don't intersect if one max value less than other's min value. The intersection point P is given by:. opencv: Combines two rotation-and-shift transformations: C M T: cv. The source code is released under:. The project is written in C++ using openCV library. up vote 1 down vote ---Accepted---Accepted---Accepted---. Determines whether CRect is equal to the given rectangle. vec -num 500 -w 20 -h 20. 저는 Python과 Opencv를 사용하고 있습니다. Quadrilateral Shape Finding Algorithm (3) I want to detect and and return the point where they intersect, easy to do mathematically. For example, all of the pixel coordinates are counted from the top-left (or bottom-left) corner of the ROI, not the original image. I'm not needed in calculation of the intersection points coordinates or how many intersection points there. ( That is , R1 is completely on the right of R2). The bgr_pixel is identical to rgb_pixel except that it lays the color channels down in memory in BGR order rather than RGB order and is therefore useful for interfacing with other image processing tools which expect this format (e. OpenCV typically assumes that the top and left boundary of the rectangle are inclusive, while the right and bottom boundaries are not. points() method. OpenCV is “Open Source Computer Vision Library”. c++ - rectangle - paper detection opencv python Detecting a sheet of paper / Square Detection; What you need is a quadrangle instead of a rotated rectangle. Let's begin with one of the simplest cases for use of a PShape. For the needed algebra bit I will be using numpy. Approach: The above problem can be solved by observation. This will draw the rectangle in these form as shown above. Coordinates of the top-left corner. A Rect can be created from a combination of left, top, width, and height values. The RETR_EXTERNAL parameter is used in the practical application, only the outline of the exterior is extracted. y in OpenCV. The source code is released under:. Create two new ‘corrected’ centers from the given center. Most OpenCV functions support the use of ROI and treat the image rectangle as a separate image. Intersecting rectangle when bottom-left and top-right corners of two rectangles are given Given coordinates of 4 points, bottom-left and top-right corners of two rectangles. If the order of the vertices of the polygon is given, we present a randomized algorithm that computes an inscribed rectangle with area at least (1 − ϵ) times the optimum with probability t in time O (1 ϵ log n) for any constant t < 1. Pre-requisite: Line Sweep Algorithms Line intersection problem is a problem solved using line sweep technique. The algorithm reads in the image and converts it using OpenCV s cvtColor() function from RGB to HSV color space. So how can we draw it? This is the big question. 1 Windows10 Word アフィン変換 アンシャープマスキング カメラ カラー光切断法. points() method. This tutorial will be focused on being able to take a picture and extract the rectangles in the image that are above a certain size: For every line compute the intersection. If you take two points on a line through origin, they have the same slope Δy Δx: 0 = a ×Pb ⇔ 0 = a. After the rectangle is rotated I need to calculate if any given point int the picture falls inside the rectangle. 0, was released in 2006 and the OpenCV community has grown leaps and. @param color Rectangle color or brightness (grayscale image). The figure module provides the top-level Artist, the Figure, which contains all the plot elements. When specifying a CRect, you must be careful to construct it so that it is normalized — in other words, such that the value of the left coordinate is less than the right and the top is less than the bottom. Open Source Computer Vision Library. My project converts the contours of the result of an edge detection to svg, to be used as path information later. In this operation, the gray level intensities of the points inside the foreground regio. Shruow says: 2017-09-11 at 17:28. Recommend：Java OpenCV deskewing a contour any other in your wallet. An image is a single frame that captures a single-static instance of a naturally occurring event. Rectangle width and height. If a window fails the first stage, discard it. In general, the. It is also compatible with the majority of dense array types from the standard toolkits and SDKs, such as Numpy (ndarray), Win32 (independent device bitmaps), and others, that is, with any array that uses *steps* (or *strides*) to compute the. Here is the code and example input image. So, you can identify any polygon by the number of vertices of that polygon. Please visit the tutorial on bounding rectangle for more information. OpenCV 3 image and video processing with Python OpenCV 3 with Python Image - OpenCV BGR : Matplotlib RGB Basic image operations - pixel access iPython - Signal Processing with NumPy Signal Processing with NumPy I - FFT and DFT for sine, square waves, unitpulse, and random signal Signal Processing with NumPy II - Image Fourier Transform : FFT & DFT. If the two rectangles do not intersect rectangle a is unchanged and the function returns false. Making statements based on opinion; back them up with references or personal experience. Though, in your algorithms you may count x and y from the bottom-left corner. OpenCV typically assumes that the top and left boundary of the rectangle are inclusive, while the right and bottom boundaries are not. As in Python, start is an inclusive left boundary of the range and end is an exclusive right boundary of the range. Similarly, for closing also. avi movie file to a set of numbered frames using OpenCV API. Detecting polygon self intersection. Detect Bounding Box In Image Python. OpenCV-Python Tutorials OpenCV introduces a new set of tutorials which will guide you through various functions available in OpenCV-Python. The legitimate OpenCV guide to installing did not work for me as well as the other guides. Instead of get_insersec_region, I would call this method __and__. 0 release, we are glad to present the first stable release in the 4. OpenCV 3 Tutorial image & video processing Installing on Ubuntu 13 Mat(rix) object (Image Container) Creating Mat objects The core : Image - load, convert, and save Smoothing Filters A - Average, Gaussian Smoothing Filters B - Median, Bilateral OpenCV 3 image and video processing with Python OpenCV 3 with Python Image - OpenCV BGR : Matplotlib RGB. If multiple points of intersection exist, randomly return one of those intersection points. Rectangle width and height. OpenCV is “Open Source Computer Vision Library”. ＊OpenCVのバージョンは2. We don't consider remaining features on it. /** * If the rectangle specified by left,top,right,bottom intersects this * rectangle, return true and set this rectangle to that intersection, * otherwise return false and do not change this rectangle. Rectangle that is the intersection of this rectangle and the gtk. opencv3_multitracking_sample. Virtually every loop over an image ROI in OpenCV (where ROI is specified by Rect_ ) is implemented as: for ( int y = roi. The coordinates for some intersection will just be the point where "edge a" of "rectangle 1" intersects "edge x" of "rectangle 2. Start by creating a new project in your IDE. 6$\begingroup\$ I'm looking for the algorithm that determines the fact that a polygon has self intersection or hasn't. Help and Feedback You did not find what you were looking for? C - Tracking objects using histogram data in OpenCV. If the rectangles do not intersect the returned gtk. Also, I'll use OpenCV's C++ interface. The green rectangle (r3) shown in figure below is the the union of red rectangles (r1 and r2). detectMultiScale • OpenCV extends NPP and uses it to build higher level CV 15. That is, if A is n-by-4 and B is m-by-4, then area is an n-by-m matrix where area(i,j) is the intersection area of the rectangles specified by the ith row of A and the jth row of B. If A and B each specify one rectangle, the output area is a scalar. In Euclidean geometry, the intersection of a line and a line can be the empty set, a point, or a line. rect = rect ± point (shifting a rectangle by a certain offset) rect = rect ± size (expanding or shrinking a rectangle by a certain amount) rect += point, rect -= point, rect += size, rect -= size (augmenting operations) rect = rect1 & rect2 (rectangle intersection) rect = rect1 | rect2 (minimum area rectangle containing rect1 and rect2 ). It’s so fast and easy you won’t want to do the math again!. Let us break the term down into its two parts — Convex and Hull. rectangle_points: Draws a simple, thick, or filled up-right rectangle. Thanks for contributing an answer to Game Development Stack Exchange! Please be sure to answer the question. If the vector mask is not selected, the Add, Subtract, Intersect and Exclude options will be grayed out and unavailable in the Options Bar. This tutorial is the second post in our three part series on shape detection and analysis. 3 thoughts on “ How to work with ROI in OpenCV ” carkode says: 2015-02-11 at 21:48 thanks…. Rectangle width and height. I'm using OpenCV and want to group together rectangles that have significant overlap. empty if the intersection of the rectangles is empty. Recommend：Java OpenCV deskewing a contour any other in your wallet. pt2fwabquzew, 0ang744aj1ljw, maw0avv8lxozl, vuhton4mmhg, p7ccrqnkfr4t88r, qonryczmrs, ncv6bgjwz559bxl, gfytsfmcqfq7, 4srgkuu12vn, qxomwamysx206r, pff1sws9ek0, vuikchyt70rg5, t36iyms7h7l, y5nfj93lqbolh4c, vjq2lb5b0a55l, hfy3vjczv63, g4qpapiwpfgkv, 7brlips9zaiff0, lgjdjr2x25gjw3, nzd6i8gc0xczpjd, 9c5vx0hv36wxk8h, fvy3rfs229ovwg, dtqk4dub3vr, j65nspcv7w4x6, sarnap0vabb1w5, 2hhhmdnkyc, tpwajix06fy5ff3, pd9mh0ncxo30, dvqlw8zih6g3jm


text:
In N-dimensional simplex noise, the squared kernel summation radius $r^2$ is $\frac 1 2$ for all values of N. This is because the edge length of the N-simplex $s = \sqrt {\frac {N} {N + 1}}$ divides out of the N-simplex height $h = s \sqrt {\frac {N + 1} {2N}}$. The kerel summation radius $r$ is equal to the N-simplex height $h$.
$r = h = \sqrt{\frac {1} {2}} = \sqrt{\frac {N} {N+1}} \sqrt{\frac {N+1} {2N}}$

format: plain


text:
# Which layer do DDD Repositories belong to?

In his DDD book Evans promotes the idea of layered architecture, and in particular that the business logic should be confined to domain layer and separated from UI/persistence/other concerns. He also introduces Repository pattern as a mean to abstract access and persistent storage to Entities and Value Objects. To me the following left unclear:

1. Which layer Repositories belong: the Domain Layer, Persistence Layer or something in the middle? (It seems that if it were below Domain Layer it would violate Layered Architecture principle, because it depends on a domain object which it stores)
2. Can Entities, Value Objects or Domain Services call Repositories?
3. Should Repositories be abstracted from storage technology (which would be implied if they belong to domain layer) or can they leverage those storage technologies?
4. Can Repositories contain business logic?
5. Have you applied these constraints in practice and what was the effect on the quality of your project?

(I am mostly interested in DDD perspective)

Repositories and their placement in the code structure is a matter of intense debate in DDD circles. It is also a matter of preference, and often a decision taken based on the specific abilities of your framework and ORM.

The issue is also muddied when you consider other design philosophies like Clean Architecture, which advocate using an abstract repository in the domain layer while providing concrete implementations in the infrastructure layer.

But here's what I have discovered, and what has worked for me, after trying out different permutation/combinations.

• From a DDD perspective, Repositories sit between Application Services and Domain Objects.
• Domain Objects encapsulate behavior and contain the bulk of business logic, enforcing invariants at the aggregate level.
• Application services receive calls from UI/API/Controllers/Channels (external facing), initial repositories to load aggregates (if needed), invoke domain model for the necessary changes, then use the repositories again to persist aggregates

Which layer Repositories belong: the Domain Layer, Persistence Layer or something in the middle?

1. I would say there are three distinct layers in DDD applications - the inner domain layer, the outer application layer, and the external world (includes the API/UI).

The domain layer contains aggregates, entities, value objects, domain services, and domain events. These elements are only dependent on each other and actively avoid dependencies any outer layers.

The application layer contains Application Services, Repositories, Message Brokers, and whatever else you need to make your application practically possible. This layer is where most of the persistence, authorization, pub-sub processing, etc. happens. Application Layer depends and knows about the domain layer elements, but follows DDD guidelines when accessing the domain model. For example, it will only invoke methods on Aggregates and Domain Services.

The outermost layer includes API Controllers, serializers, authentication, logging, etc., whatever is not related to business logic or your domain, but very much part of your application.

Can Entities, Value Objects or Domain Services call Repositories?

1. No. The domain layer should preferably remain agnostic to repositories. Application services should take on the responsibility of transactions and repository interactions.

Should Repositories be abstracted from storage technology (which would be implied if they belong to domain layer) or can they leverage those storage technologies?

1. Repositories lean towards the domain side, meaning they contain methods that are meaningful from a domain point of view (like GetAdults() or GetMinors()). But the concrete implementation can be done in a couple of ways:

• You could use an abstract repository to declare the necessary methods, and then create concrete implementations for different databases. The database implementation can be chosen at the beginning of application startup, based on your configurations. Note that even in this case, Domain layer has nothing to do with repositories
• Repositories could act like wrappers and make use of underlying DAO objects (one per table/document) that implement the actual logic for interacting with the database. The DAO objects are initialized usually with dependency injection if your framework/language supports it, or they could be initialized manually based on active configuration.

1. Repositories represent domain concepts, with meaningful method names, but seldom contain any business logic. They encapsulate the database query and give it a conceptual name that usually is derived directly from the ubiquitous language. It is so much better to have a method called GetAdults() instead of .filter(age > 21).

Have you applied these constraints in practice and what was the effect on the quality of your project?

1. If you restrict yourself to using repositories only in application services, and control transactions at one place (usually with Unit of Work pattern), Repositories are pretty easy to work with. In my past projects, I have found it extremely useful to restrict all database interaction to repositories instead of sprinkling lifecycle methods in the domain layer.

When I called lifecycle methods (like save, update, etc.) from the aggregate layer, I found it to be extremely complex and difficult to reliably control ACID transactions.

• 2. The fact, that repository is inaccessible in domain services and domain objects, forces a programmer to disperse each operation between application services, domain services and/or domain objects. Is it ends up being awkward in practice? – Alexey Aug 18 at 9:55
• 4. GetAdults - if we are writing an international application, the definition of adult can be quite non-trivial and pollute the repository with the business logic. This probably might push a developer to implement some query object, that would specify to repository what is 'adult'. Which leads to some artificial complexity to ensure purity. Do you prefer in such cases to pollute repositories or what is your preferred approach? – Alexey Aug 18 at 10:08
• 1. Do you mean, that both domain layer and persistence (infrastructure) layer sit below application layer and are isolated from each other? – Alexey Aug 18 at 10:12
• 2. It makes it easier to reason with. And you actually put it beautifully :) When you say "dispersing of operation," it is actually "separation of concerns." Doing so, as you already know, has many benefits, like robustness, testability, ability to metaprogramme and reduce code, etc. – Subhash Bhushan Aug 19 at 16:00
• 4. I have come across this puzzle, and this is what I think: Repositories are supposed to be lean while still representing domain concepts from the ubiquitous language. When I see business logic in the repository, there is a good chance that it needs to be pushed back in the aggregate/domain layer. In the specific example of GetAdults, in a realistic scenario, I would tie this configuration as a "tenant" preference, where the tenant (client) specifies the location of its operations (from which, we derive the adult age based on a system configuration). – Subhash Bhushan Aug 19 at 16:07

Which layer Repositories belong: the Domain Layer, Persistence Layer or something in the middle?

If you believe in dependency inversion*, then repositories are contracts defined by the application layer and implemented by the persistence layer. The contract itself has an implicit dependency on the domain model (via the appearance of the domain entities in the signature), and the implementation of a repository will often include a direct dependency on the factory responsible for creating instances.

Can Entities, Value Objects or Domain Services call Repositories?

Ideally, they should not need to. The domain model sits at the core of the onion; it's a pure in memory representation of (a part of the) domain.

You may sometimes see a domain service that acts as a facade provides a read-only view of cached data. But writing to a repository from the domain model is normally out of bounds (the dependency arrows don't point that direction).

Should Repositories be abstracted from storage technology

Ideally, the repository contract explicitly describes the capabilities required by the application, without necessarily coupling you to a specific technology.

In its ideal form, a repository is a facade for a domain agnostic collection. So no. This is somewhat connected to the previous question; if the implementation of the repository includes important business logic, it becomes that much harder to find the logic, and to recognize the implications that logic has on your choice of storage.

A real portion of the motivation for these patterns is an attempt to make them easier to maintain -- which includes making it easier to guess where in the code base some important concept is going to be realized.

Have you applied these constraints in practice and what was the effect on the quality of your project?

This is pretty subjective, but I haven't found much joy in the repository pattern as described by Evans. Part of the problem is that the patterns are very much based in the Kingdom of Nouns; another is that they appear to be coupled to the idioms of Java circa 2003.

The idea is right -- the application shouldn't need to know the details of where mutable state is managed. We can correctly place a boundary between those concepts. Similarly, the domain model should be independent from its application host, so that the host can be changed.

Where things tend to break down is save. How do you get the data you need out of the object and into your storage? The domain model has it, the repository needs it, so you end up with some persistence pollution entering your "pure" domain model. The pollution can take a number of forms -- ORM hooks, public members, serialization APIs....

Let's assume that Entities have to be immutable. By definition repository is an emulation of in-memory collection of entities, sort of Map

Very close. It's probably a better fit, semantically, if you think in terms of messages, rather than entities. Both the domain model and persistence need to know how to extract information from the messages to get their job done. See Boundaries, by Gary Bernhardt

Alternatively, you can keep the idea of the repository that stores mutable entities (somewhere), by separating those entities from the business logic. In that approach, the entity API is consumed by the domain model, but implemented by the persistence component. This keeps the mutable state out at the boundary of your solution, where it belongs.

* The term "Dependency Inversion" is as ill-defined as all of the other SOLID principles, and articles on the internet all parrot the same tired phrases to define it. For purposes of this answer, dependency inversion can be defined as "handing a class its concrete dependencies through constructor parameters that are defined by interfaces." See here for an example.

• "Where things tend to break down is save" - I think to determine where 'save' belongs it helps to set a thought experiment. Let's assume that Entities have to be immutable. By definition repository is an emulation of in-memory collection of entities, sort of Map. So it's a natural workflow: entity = repository.get(id); repository.put(id, computeNewEntityState(entity)); So to me save (e.i. put) is a naturally belongs to Repository. – Alexey Aug 18 at 9:43
• Just a quick remark: I wouldn't say that "dependency inversion" is ill defined, and it certainly predates SOLID. I'm not arguing against the "for purposes of this answer" part - that's perfectly fine; but in general what you described is constructor injection. Starting with A --> B ("A depends on B"), dependency inversion is about extracting some stable aspect of that interaction into some construct C (class, interface, data structure, contract, convention), and then writing all code of A in terms of C, and all implementation in B behind C, so that [A-->C] <---B ("B depends on A+C"). – Filip Milovanović Aug 18 at 13:25
• @FilipMilovanović: Which is exactly what constructor injection achieves. (That edit is mine). – Robert Harvey Aug 18 at 13:56
• @RobertHarvey: Yes - I'm not saying it doesn't, just that it's a specific way to achieve the inversion. For example, in compiler designs where you have a front end and back end and an intermediate representation (IR) between them, the IR is an abstraction that facilitated dependency inversion between the two components. What I'm trying to say is that the notion of dependency inversion is more general then the practice of d. injection. – Filip Milovanović Aug 18 at 14:27
• @FilipMilovanović: Yeah, I wouldn't have thought of that. I see IR as a form of decoupling, albeit a very sophisticated one. DI is more commonly associated with line of business software architectures. – Robert Harvey Aug 18 at 15:21

So, if you disregard all the "aggregate design rules" talk you can find on the net, and focus on how aggregates are described in the book, they are meant to be these bundles of objects that form some sort of a graph, with an explicit design boundary, and one object selected as the root. The root acts as an interface (facade) to the aggregate, it encapsulates it, and is responsible for maintaining consistency within that boundary. Your domain model is then, more or less, composed of a number such aggregates that can be reached by traversal. Another important role the aggregates have is to simplify the web of dependencies between objects, so aggregate relationships should be strategically designed.

The question is, how do you obtain the initial aggregates - the ones you start the traversal from?

If you take a closer look at how Evans defined repositories, the emphasis is not on persistence (although generally speaking they do eventually end up going to the database) - instead they are a means to obtain the initial "surface level" aggregate roots, letting you start there and reach the others via traversal.

To quote the Blue Book:

"Whether to provide a traversal or depend on a [database] search becomes a design decision, trading off the decoupling of the search against the cohesiveness of the association. [...] The right combination of search and association makes the design comprehensible."

That means that the dependency structure is such that (1) when an execution path is entered, a Use Case1 that needs an aggregate must ask a repository to obtain one, and (2) the the repository knows about certain "surface level" aggregates, but the core domain doesn't know about repositories.

There is some room for variation when it comes to how you organize that into layers, but you can see that the above structure imposes some constraints on the dependency directions across and within layers. So to answer you question.

1. Which layer Repositories belong: the Domain Layer, Persistence Layer or something in the middle?

A repository as conceptualized by DDD is an abstraction - it is not itself in the persistence layer, it encapsulates database access - meaning that it forwards reconstitution request to some data access gateway that is in the persistence layer (either via composition, or via dynamic dispatch).

"For each type of object that needs global access [...] set up access through a well-known global interface. [Repositories encapsulate] the actual storage and query technology. Provide REPOSITORIES only for AGGREGATE roots that actually need direct access."

They are meant to be accessible throughout the application layer, so that seems to be a natural place for them to reside, but the actual implementation will go across layers. The reason for the encapsulation is to keep application service layer code simple and decoupled from persistence-related boilerplate.

(It seems that if it were below Domain Layer it would violate Layered Architecture principle, because it depends on a domain object which it stores)

The repository abstraction is not below the Domain Layer, but it does depend on the domain objects - that's the whole point. You ask it for an aggregate root using the language of the domain model (e.g., you pass it an ID), it then figures out how to turn that into a database query; the database returns its representation, and the repository then uses it to reconstitute the requested aggregate, and returns that. Beyond that, it doesn't contain any significant business logic, and it certainly doesn't contain any problem-specific (core) domain logic. In practice, though, you want to try and arrange things in a way that avoids elaborate and costly translations between representations.

Another thing that is discussed in the book is that it is desirable to find a way to express aggregate boundaries in the code itself, but that it can be a bit tricky to do so. The most common thing you'll find on the web is the idea popularized by Vaughn Vernon, that states that aggregates should reference other aggregates exclusively via their identity. This can work well in many cases, and has the advantage of clearly delineating aggregate boundaries in code, but IMO it's too restrictive and somewhat database-centric in thinking for it to be elevated to the status of a rule that you enforce or even default to when it comes to aggregate design. So don't think of it as the only option - you could design a different scheme.

If you do go down that path, then you have to figure out how to traverse across aggregates given that specific restriction. Vaughn Vernon recommends to "use a repository or domain service to look up dependent objects ahead of invoking the aggregate behavior" (and not use a repository from within the aggregate, to prevent the aggregates from having a dependency on one or more repositories).

There's a bit of a tradeoff here (as with every design decision): A certain amount of knowledge about the inner workings of the aggregate is being pushed elsewhere, and the signatures of the aggregates' methods become more verbose (and some of the dependencies less obvious as they aren't visible in the constructor).

This is a viable approach, but it should be noted that it's a little different than what's described in Evans' book - where the idea was to be very deliberate about which aggregate roots should be obtained through repositories, and which via traversal, and under what circumstances - based on your understanding of the domain, business processes, access patterns, etc.

1 The two layers of interest here, in DDD terminology, are the Application Layer and the Domain Layer. The Application Layer ("defines the jobs the software is supposed to do and directs the expressive domain objects to work out problems") roughly corresponds to the Application Business Rules (Use Cases) layer in Clean Architecture ("use cases [...] direct [the] entities to use their enterprise wide business rules to achieve the goals of the use case").

• To clarify your answer. In DDD Book by Evans he defines aggregates as a "unit of change". So if we invoke a method on an aggregate root, it should not use navigation outside of the aggregate, i think. This would violate our expectations of what can be affected by such method. Instead such navigation should be used only in application or domain services. *** Also navigation-vs-lookup choice defines what a domain service can do. Because domain service cannot depend on a repository, it can use navigation, but not a lookup. – Alexey Aug 18 at 15:48

According to dddsample you can have a Repository as interface(CargoRepository) in domain layer and actual implementation(CargoRepositoryHibernate) in Infrastructure layer.

Layered Architecture picture (also from DDD blue book):


text:
# Boundaries on the single-period returns

I know that $$e^{t\mu_{\operatorname{log}}-\Gamma\sqrt{t}\sigma_{\operatorname{log}}}\leq \widetilde{R}_t^S \leq e^{t\mu_{\operatorname{log}}+\Gamma\sqrt{t}\sigma_{\operatorname{log}}}$$, with $$\mu_{\operatorname{log}},\sigma_{\operatorname{log}},\Gamma \in \mathbb{R}^+$$ and $$\widetilde{R}_t^S:=\prod_{i=1}^{t-1}(1+\widetilde{r}_t^S)$$. Note that this interval results from $$\left | \frac{\frac{1}{t}\operatorname{log}\widetilde{R}_t^S-\mu_{\operatorname{log}}}{\frac{\sigma_{\operatorname{log}}}{\sqrt{t}}} \right | \leq \Gamma$$, in its turn obtained from the Central Limit Theorem $$\left | \frac{\frac{1}{n}\sum_{i=1}^{n}X_i-\mu}{\frac{\sigma}{\sqrt{n}}} \right |\overset{d}{\rightarrow} \operatorname{N}(0,1)$$. How can I prove that the interval for $$\widetilde{r}_t^S$$ is

$$\left | \widetilde{r}_t^S-\mu \right |\leq \Gamma\sigma \space \Rightarrow \space \mu-\Gamma\sigma \leq \widetilde{r}_t^S \leq \mu+\Gamma\sigma$$

knowing that $$\frac{\widetilde{R}_{t+1}^S}{\widetilde{R}_t^S}=1+\widetilde{r}_t^S$$?

Thanks for any help.

• Probably using a Taylor expansion of the exponent or log... – steveo'america Nov 24 '20 at 17:31
• @steveo'america That is to say? – Marco Pittella Nov 25 '20 at 8:48


text:
# A classical mechanics problem by Edward Gleason

Classical Mechanics Level pending

A ball is dropped from the edge of a cliff 100 meters from the ground. At the same time, a car that is 100 meters from the cliff base starts from rest toward the cliff. How fast will the car have to accelerate toward the cliff so that it arrives at the cliff base at the same moment the ball reaches the ground? (Ignore air resistance and presume the driver isn't afraid of death.) Use 10 meters per second squared as the surface gravity value.

×


text:
# What sort of cardinal number is the Löwenheim–Skolem number for second-order logic?

In their paper “On Löwenheim–Skolem–Tarski numbers for extensions of first order logic”, Magidor and Väänänen make the following statement:

“For second order logic, $$\mathrm{LS}(L^{2})$$ [the Löwenheim–Skolem number for second order logic—my comment] is the supremum of $$\Pi_{2}$$-definable ordinals..., which means that it exceeds the first measurable, the first $$\kappa^{+}$$-supercompact $$\kappa$$, and the first huge cardinal if they exist”.

[“The Löwenheim–Skolem number $$\mathrm{LS}(L^{2})$$ of second order logic $$L^{2}$$ is the smallest cardinal $$\kappa$$ such that if a theory $$T\subset L^{2}$$ has a model, it has a model of cardinality $$\le\max(\kappa,|T|)$$”, and “$$L^{2}$$ extends first order logic with quantifiers of the form $$\exists R\,\phi(R,x_0,\dots,x_{n-1})$$, where the second order variable $$R$$ ranges over $$n$$-ary relations on the universe for some fixed $$n$$”—my comment also but substantially quoting the authors.]

Assume that the first measurable, the first $$\kappa^{+}$$-supercompact $$\kappa$$, and the first huge cardinals exist. What type of large cardinal, then, is $$\mathrm{LS}(L^{2})$$? If the answer is known, please provide the reference.

• Magidor has results on this. Jul 19, 2015 at 3:49
• Why did this get a -1? Seems a fine question to me. Jul 19, 2015 at 4:23
• Thomas, in your definition of the Löwenheim-Skolem number, shouldn't it be $\kappa\leq\text{max}(\kappa,|T|)$, rather than $<$? Jul 19, 2015 at 12:20
• Strange. Wikipedia defines it as I suggest, and that definition makes sense to me: en.wikipedia.org/wiki/L%C3%B6wenheim_number#Extensions. Jul 20, 2015 at 1:10
• @JoelDavidHamkins is right. You can't reasonably expect to get models of $T$ that are smaller than $|T|$. Jul 20, 2015 at 15:10

The following is due to Magidor:

Theorem 1. Is $\kappa$ is a strong cardinal, then $LS(L^2) < \kappa.$

The proof if easy. Let $T \subseteq L^2$ be a theory and let $A$ be a model for $T$. e may assume the universe is some cardinal $\delta.$ Take some cardinal $\beta > \beth_{\omega}(\delta)$, and let $j: V \to M$ witness $\kappa$ is $\beta$-strong. It is easily seen $M\models$$A \models T$'', so $M \models \exists B( B \models T, |B| < j(\kappa))$. By elementarity in $V$, $T$ has a model of size $< \kappa.$

Also note that for any theory $T \subseteq L^2,$ there is a least $\delta_T$ such that if $T$ has a model, then it has a model of size $< \delta_T.$ Then $LS(L^2)=\sup \{\delta_T: T$ as above $\}$, so $LS(T^2)$ can be singular, even though it can be above some very large cardinals.

The Löwenheim number (compared to LS, this uses sentences rather than theories) for the second order logic $$L^2$$ is the least $$κ$$ such that $$V_κ$$ satisfies all true $$Σ_2$$ sentences. This $$κ$$ has cofinality $$ω$$, and $$V_κ$$ does not satisfy ZFC, but $$κ$$ is a limit of large cardinals. For example, if there is a proper class of huge cardinals, then $$κ$$ is a limit of huge cardinals, and same with other $$Σ_2$$ properties.

Assuming countable vocabulary, the Löwenheim-Skolem (LS) number for $$L^2$$ is the least $$κ$$ such that $$V_κ$$ satisfies all true $$Σ_2$$ sentences with real parameters. $$ω_1≤\operatorname{cf}(κ)≤c$$, where $$c$$ is the cardinality of the continuum. As before, $$V_κ$$ does not satisfy ZFC, but $$κ$$ is a limit of large cardinals.

If we allowed a proper class of constant symbols, then $$L^2$$ would not have a Löwenheim-Skolem number. Still, even then, if $$V_κ ≺_{Σ_2} V$$, then every theory of cardinality $$<κ$$ with an $$L^2$$ model has such a model of cardinality $$<κ$$. For reference, among $$κ$$ with $$V_κ ≺_{Σ_2} V$$, the following are in strictly increasing order of the least example (if any, if not assuming large cardinals): $$\operatorname{cf}(κ)=ω$$, $$\operatorname{cf}(κ)=ω_1$$, $$V_κ⊨\text{ZFC}$$, $$\operatorname{cf}(κ)=ω_1 ∧ V_κ⊨\text{ZFC}$$, $$κ$$ is regular, $$κ$$ is Mahlo, $$κ$$ is weakly compact, $$κ$$ is measurable, $$κ$$ is strong. Note that for every strong $$κ$$, $$V_κ ≺_{Σ_2} V$$.

Also, the Löwenheim-Skolem-Tarski (LST) number of a logic $$L$$ is the smallest cardinal $$κ$$ such that every structure for $$L$$ has an elementary substructure of size $$≤κ$$. As noted in the paper in the question, the LST number for $$L^2$$ (with countable vocabulary) is the least supercompact cardinal, or none if none exists; the Vopěnka's principle holds iff every logic with set-sized vocabulary has an LST number.


text:
Next: 5.1.3 HJB equation Up: 5.1 Dynamic programming and Previous: 5.1.1 Motivation: the discrete   Contents   Index

## 5.1.2 Principle of optimality

We now return to the continuous-time optimal control problem that we have been studying since Section 3.3, defined by the control system (3.18) and the Bolza cost functional (3.21). For concreteness, assume that we are dealing with a fixed-time, free-endpoint problem, i.e., the target set is . (Handling other target sets requires some modifications, on which we briefly comment in what follows.) We can then write the cost functional as

As we already remarked in Section 3.3.2, a more accurate notation for this functional would be as it depends on the initial data.

The basic idea of dynamic programming is to consider, instead of the problem of minimizing for given and , the family of minimization problems associated with the cost functionals

 (5.1)

where ranges over and ranges over ; here on the right-hand side denotes the state trajectory corresponding to the control and satisfying . (There is a slight abuse of notation here; the second argument of in (5.1) is a fixed point, and only the third argument is a function of time.) In accordance with Bellman's roadmap, our goal is to derive a dynamic relationship among these problems, and ultimately to solve all of them.

To this end, let us introduce the value function

 (5.2)

where the notation indicates that the control is restricted to the interval . Loosely speaking, we can think of as the optimal cost (cost-to-go) from . It is important to note, however, that the existence of an optimal control--and hence of the optimal cost--is not actually assumed, which is why we work with an infimum rather than a minimum in (5.2). If an optimal control exists, then the infimum turns into a minimum and coincides with the optimal cost-to-go. In general, the infimum need not be achieved, and might even equal for some .

It is clear that the value function must satisfy the boundary condition

 (5.3)

In particular, if there is no terminal cost ( ) then we have . The boundary condition (5.3) is of course a consequence of our specific problem formulation. If the problem involved a more general target set , then the boundary condition would read for .

The basic principle of dynamic programming for the present case is a continuous-time counterpart of the principle of optimality formulated in Section 5.1.1, already familiar to us from Chapter 4. Here we can state this property as follows, calling it again the principle of optimality: For every and every , the value function defined in (5.2) satisfies the relation

 (5.4)

where on the right-hand side is the state trajectory corresponding to the control and satisfying . The intuition behind this statement is that to search for an optimal control, we can search over a small time interval for a control that minimizes the cost over this interval plus the subsequent optimal cost-to-go. Thus the minimization problem on the interval is split into two, one on and the other on ; see Figure 5.3.

The above principle of optimality may seem obvious. However, it is important to justify it rigorously, especially since we are using an infimum and not assuming existence of optimal controls. We give one half" of the proof by verifying that

 (5.5)

where denotes the right-hand side of (5.4):

By (5.2) and the definition of infimum, for every there exists a control on such that

 (5.6)

Writing for the corresponding state trajectory, we have

where the two inequalities follow directly from the definitions of and , respectively. Since (5.6) holds with an arbitrary , the desired inequality (5.5) is established.

Next: 5.1.3 HJB equation Up: 5.1 Dynamic programming and Previous: 5.1.1 Motivation: the discrete   Contents   Index
Daniel 2010-12-20


text:
# Coulomb's law universal or not?

1. Mar 22, 2008

### manjuvenamma

What exactly is meant by universal law? I have read in a book a that Ohm's law is not a univeral law. I somewhat understood that as Ohm's law is not obeyed by all materials and not always. But I read now in another book that Coulomb's law is also not a universal law. Now I am beginning to wonder what is a univeral law.

2. Mar 22, 2008

### Archduke

Coulomb's law only works for a point charge, and not for all charge distributions. As it only works in certain situations (as does Ohm's Law), then it is not universal. A universal law will work in any situations.

3. Mar 22, 2008

### manjuvenamma

I did not get what you mean by the law not applicable to charge distributions. For charge distributions too we can still apply the law individually for each charge and get the results. Like we have the force calculations for a line charge or sheet of charge. Even the gravitational law consider bodies with masses as particles, so is gravitational law too not universal. You must be right, but I think I am missing a point. If you can elaborate, that will help.

4. Mar 22, 2008

### nicksauce

Well you can't just blindly apply Coulomb's law if the charges in question have a velocity or an acceleration.

5. Mar 22, 2008

### Staff: Mentor

Coulomb's law is a simplification of Maxwell's equations under specific conditions (electrostatic = no moving charges). The universal law is Maxwell's equations which are hard to solve sometimes. So you use the simpler Coulomb's law where you can and the more complicated but universal Maxwell's equations when you need to.

PS Coulomb's law is not the only simplified form of Maxwell's equations that is in widespread use, but it is the first one that you encounter in a typical course of study.

Last edited: Mar 22, 2008
6. Mar 22, 2008

### Ataman

So why does Coulomb's Law not work for charges in Motion?

-Ataman

7. Mar 22, 2008

### Staff: Mentor

Coulomb's law gives you the electric field. If a charge is moving you need to consider the magnetic field also.

8. Mar 22, 2008

### manjuvenamma

Friends,
I agree with you all. I am now convinced/enlightened why the law is not universal. Thanks.

9. Mar 23, 2008

### cepheid

Staff Emeritus
Am I to understand that, in contrast, Gauss' law IS universal. In other words, although you can derive it from Coulomb's law in the context of electrostatics, it is actually applicable outside of that context as well?

10. Mar 23, 2008

### nicksauce

Well Gauss's law is one of Maxwell's equations, which are universal, whereas Coulomb's law is not.

11. Mar 23, 2008

### rbj

there seems to be something wrong with this thread. Gauss's Law is a direct consequence of any inverse-square law. if it's inverse-square (and additive, i.e. superposition applies), then Gauss's Law applies.

so is the implication here that Coulomb's Law is not inverse-square?

BTW, from a POV of classical, non-relativistic physics, yes Coulomb's law is lacking because it does not describe the electromagnetic interaction. but if Special Relativity is considered, that plus Coulomb's Law suffices, i think.

i would say that the premise of the question (and many of the responses) is wrong. Coulmb's Law is quite universal. but like other universal laws, it's not the only one.

Last edited: Mar 23, 2008
12. Mar 23, 2008

### Staff: Mentor

Gauss's law and Coulomb's law are equivalent. You can derive either from the other quite easily. By "not universal" I simply meant to imply that Gauss/Coulomb is only one part of Maxwell, which is the "universal" law. Gauss/Coulomb always applies, but whenever you have moving charges it is insufficient to predict the behavior without the other Maxwell equations.

OK, I am fine with that too. "Universal" but not "complete".

13. Mar 23, 2008

### nicksauce

"
there seems to be something wrong with this thread. Gauss's Law is a direct consequence of any inverse-square law. if it's inverse-square (and additive, i.e. superposition applies), then Gauss's Law applies."

Sorry the point I was trying to make was that Gauss's Law always applies as it is one of Maxwell's equation, and Coulomb's law is only a solution of the Maxwell equations when things aren't changing with time. Does that make it not universal? It depends on what one means by universal.

14. Mar 23, 2008

### rbj

it is not that either. it is what is usually enumerated as the first of Maxwell's equations.

$$\nabla \cdot \mathbf{E} = \frac {\rho} {\epsilon_0}$$

is the differential expression of

$$\oint_S \mathbf{E} \cdot \mathrm{d}\mathbf{A} = \frac {Q_S}{\epsilon_0}$$

while that is a direct expression of Gauss's Law, that expression follows directly from the fact that Coulomb's Law is inverse-square and submits itself to superposition.

what i usually mean by "universal" is that it is as applicable to the aliens on the planet Zog as it is to us here.

15. Mar 23, 2008

### nicksauce

Ok sure, but if $$\frac{\partial \rho}{\partial t} \neq 0$$, then $$\vec{E} = \frac{q}{4\pi\epsilon_0r^2}\vec{r}$$ will not be a solution of Maxwell's equations. The impression I got from the initial post was that 'universal' is to mean 'always applies'.

16. Mar 23, 2008

### Staff: Mentor

I think that is too liberal a definition. By that definition Ohm's law is universal too.

To the OP: I think these last few posts make it clear that there is no clear definition of a "universal" law.

Last edited: Mar 23, 2008


text:
# Category:Synapse

Jump to: navigation, search

## Pages in category "Synapse"

The following 17 pages are in this category, out of 17 total.


text:
Monday, October 17, 2011

ON OBAMA'S WATCH

Losing our Ability to Define ourselves as a Nation
If you remember on the 10th anniversary of 9/11, not one single network mentioned that Islamic terrorists killed 3,000 innocent people. It’s like ignoring the 400 pound gorilla in the kitchen. If we don’t talk about it, perhaps it would vanish on its own. Instead, since 1990, we imported over 7 million Muslims into this country to prove to ourselves that we are a multi-cultural society. In the process, Michael Savage said, “America has lost its ability to define itself and defend itself.”.....
http://www.newswithviews.com/Wooldridge/frosty706.htm
by Frosty Wooldridge


text:
# Thread: Help with linear transformation

1. ## Help with linear transformation

Hi guys.
I need to prove the following:

Let $V$ be a vector space over $\mathbb{R}$, such that $dim(V)>1$.
Let $\varphi:V\rightarrow V$ be a linear transformation such that: $\varphi^2=-I$.
Prove that for every $v\neq 0$: $v,\varphi(v)$ are linear independent.

This is what I tried so far:
Let $v\in V$.
suppose $\alpha_1v+\alpha_2\varphi(v)=0$, I need to prove $\alpha_1=\alpha_2=0$.
since $\varphi$ is linear, and $\alpha_1v+\alpha_2\varphi(v)=0$, then also $\varphi(\alpha_1v+\alpha_2\varphi(v))=0$, and then:
$\varphi(\alpha_1v+\alpha_2\varphi(v))=0$
$\varphi(\alpha_1v)+\varphi(\alpha_2\varphi(v)))=0$
$\alpha_1\varphi(v)+\alpha_2\varphi^2(v)=0$ now since $\varphi^2=-I$:
$\alpha_1\varphi(v)-\alpha_2v=0$

but now I'm not sure what conclusion should I draw from this...

I can really use some guidance here.

2. ## Re: Help with linear transformation

Originally Posted by Stormey
Hi guys.
I need to prove the following:

Let $V$ be a vector space over $\mathbb{R}$, such that $dim(V)>1$.
Let $\varphi:V\rightarrow V$ be a linear transformation such that: $\varphi^2=-I$.
Prove that for every $v\neq 0$: $v,\varphi(v)$ are linear independent.

This is what I tried so far:
Let $v\in V$.
suppose $\alpha_1v+\alpha_2\varphi(v)=0$, I need to prove $\alpha_1=\alpha_2=0$.
since $\varphi$ is linear, and $\alpha_1v+\alpha_2\varphi(v)=0$, then also $\varphi(\alpha_1v+\alpha_2\varphi(v))=0$, and then:
$\varphi(\alpha_1v+\alpha_2\varphi(v))=0$
$\varphi(\alpha_1v)+\varphi(\alpha_2\varphi(v)))=0$
$\alpha_1\varphi(v)+\alpha_2\varphi^2(v)=0$ now since $\varphi^2=-I$:
$\alpha_1\varphi(v)-\alpha_2v=0$

but now I'm not sure what conclusion should I draw from this...

I can really use some guidance here.
Hi Stormey!

Suppose $v,\varphi(v)$ are linearly dependent.
Then there is some $t \in \mathbb R$ such that $\varphi(v) = t v$.

What do you get for $\varphi(\varphi(v))$?

3. ## Re: Help with linear transformation

Hi ILikeSerena!
Thanks for the help.

let me see if I got it right:

if $\varphi(v)=tv$, then $\varphi(\varphi (v))=\varphi(tv)$, and then we'll get a contradiction since:

$\varphi(\varphi (v))=\varphi(tv)$
$t\varphi(v)=-v$
$\varphi(v)=-\frac{1}{t}v$ (because according to the assumption $t\neq 0$)
$t=-\frac{1}{t}$
$t^2=-1$
no solution in $\mathbb{R}$

?

Yep!


text:
# Can I shift this integral along the complex plane?

Does

$$\int_{-\infty}^\infty \text{e}^{\ a\ (x+b)^2}\ \text dx=\int_{-\infty}^\infty \text{e}^{\ a\ x^2}\ \text dx\ \ \ \ \ ?$$

hold, even if the imaginary part of $b$ is nonzero?

What I really want to understand is what the phrase "By analogy with the previous integrals" means in that link. There, the expression $\frac{J}{a}$ is complex but they seem to imply the integral can be solved like above anyway.

The reusult tells us that the integral is really independend of $J$, which is assumed to be real here. I wonder if we can also generalize this integral to include complex $J$. In case that the shift above is possible, this should work out.

But even if the idea is here to perform that substitution, how to get rid of the complex $a$ to obtain the result. If everything is purely real or imaginary, then this solves the rest of the problem.

-
Links to the answer by username RaymondManzoni, see here as well as here. – NikolajK Aug 16 '12 at 18:15

Let us write $b= r+it$. The real part of $b$ does not matter as you have already proven yourself. So wlog $r=0$.

For shifting along the imaginary axis, we have to employ the residue theorem. We have \begin{align} \int_{-\infty}^\infty f(x+i t) \,dx&- \int_{-\infty}^\infty f(x)\, dx\\ &=\int_{-\infty-it}^{\infty-it} f(x) \,dx- \int_{-\infty}^\infty f(x)\, dx \\ &= 2\pi i \sum \text{Res}(f)+ \int_{\infty-it}^{\infty} f(x) \,dx - \int_{-\infty-it}^{-\infty} f(x) \,dx \end{align}, where $\sum \text{Res}(f)$ is the sum over the residues of $f$ in the area $z\in \mathbb{C}$ with $-t<\text{Im}\, z<0$.

So the two integrals are the same if there are no residues and if the two integral at $\pm \infty$ vanish (both of which is the case for your example as long as $\text{Re}\,a <0$).

-

Another approach that sometimes simplifies this sort of issue is to invoke the "identity principle": when the integral is holomorphic as a function of the parameter (some potential danger here!), the outcome can be computed in a convenient range, and then invoke the identity principle to know that the same formula holds for all (!) parameter values.

In the case at hand, this approach does succeed.

Beware, in cases like Cauchy's formula for $z$ inside a circle $\gamma$, $f(z)={1\over 2\pi i}\int_\gamma {f(\zeta)\;d\zeta\over \zeta-z}$, the integrand is not holomorphic in the parameter $z$ as it crosses the circle. That is, certainly the integral represents $f(z)$ for $z$ inside, but not outside, where it is $0$.

Also, in the context in which such questions would arise, it might be reasonable to be more careful about "moving contours": note that $\int_{=\infty}^{+\infty}$ is really a limit of integrals $\int_{-M}^N$, and, thus, a contour-shift uses an integral over a rectangle (or parallelogram!) with one side the interval $[-M,N]$. This, too, legitimizes the change of variables for complex parameter values.

-

Put $$(x+b)^2=u^2\Longrightarrow 2(x+b)dx=2udu\Longrightarrow dx= du$$ so we get

$$\int_{-\infty}^\infty e^{a(x+b)^2}dx=\int_{-\infty}^\infty e^{au^2}du$$ and your question's answered in the affirmative.

Added: You may want to divide the integral in two rays $\,(-\infty,0)\,,\,(0,\infty)\,$ and then do the above, to avoid problems with the signs after taking the square root.

-
You didn't shift the integral path in the complex direction. – NikolajK Aug 16 '12 at 16:10
I'm not sure I need that as the part $\,b\,$ plays in the above is almost as a dummy variable: it disappears altogether when the variable change is done. Yet I must confess I am not sure about what you say. – DonAntonio Aug 16 '12 at 16:13
But if $\Im b\neq 0$, you are moving the integration path (the integral $\int_{-\infty}^\infty$ is to be understood as being on the real line, unless explicitly specified otherwise). This is different to the purely real case where you only move the integration path along the real line (which, given that you integrate along the complete real line, doesn't matter). – celtschk Aug 16 '12 at 16:17
Ok @celtschk , I think I see your point about $\,int_{\infty}^\infty\,$ . I'll take a while to think about this and check whether I can come up with something I consider worthwhile, otherwise I shall delete my answer. Thank you and Nick – DonAntonio Aug 16 '12 at 16:19
@DonAntonio: I think that he is bothered by the real-imaginary rotation in the wikipedia link (the previous paragraph had a real integral now 'by analogy' we got a integral with a $i$ added without changing the path of integration i.e. without multiplying by $i$). This analogy is often explained by analytic continuation... – Raymond Manzoni Aug 16 '12 at 16:19


text:
In the last class, we saw the following results;
Necessity: the value function of the dynamic problem V becomes the fixed point of the corresponding Bellman problem, i.e., TV=V.
Sufficiency: if the bounded function U satisfies TU=U in a Bellman problem and if there exists a maximizing selection for TU, then U is a value function of the original dynamic problem.

Our focus on Lecture 3 is to prove these results formally and to derive some other properties about Bellman operator T.

Topics in the class

1) The proof of necessity
2) The proof of sufficiency
To read the chapter 4 of SLP in advance helped me a lot to understand the proof. Although Chapter 4 deals with DP under certainty, it has direct link to uncertain case which was covered in the class.

3) Finding a value function
(a) The Bellman operator is a contraction (by Blackwell)
(b) The set of bounded and continuous functions with sup-norm is a complete metric space. Completeness is quite important to derive properties of value functions, because it assures the properties in the limit (=the value function).