repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/abst/fiducial/CalibrationFiducialDetector.java
CalibrationFiducialDetector.getCenter
@Override public void getCenter(int which, Point2D_F64 location) { CalibrationObservation view = detector.getDetectedPoints(); location.set(0,0); for (int i = 0; i < view.size(); i++) { PointIndex2D_F64 p = view.get(i); location.x += p.x; location.y += p.y; } location.x /= view.size(); location.y /= view.size(); }
java
@Override public void getCenter(int which, Point2D_F64 location) { CalibrationObservation view = detector.getDetectedPoints(); location.set(0,0); for (int i = 0; i < view.size(); i++) { PointIndex2D_F64 p = view.get(i); location.x += p.x; location.y += p.y; } location.x /= view.size(); location.y /= view.size(); }
[ "@", "Override", "public", "void", "getCenter", "(", "int", "which", ",", "Point2D_F64", "location", ")", "{", "CalibrationObservation", "view", "=", "detector", ".", "getDetectedPoints", "(", ")", ";", "location", ".", "set", "(", "0", ",", "0", ")", ";",...
Returns the detection point average location. This will NOT be the same as the geometric center. @param which Fiducial's index @param location (output) Storage for the transform. modified.
[ "Returns", "the", "detection", "point", "average", "location", ".", "This", "will", "NOT", "be", "the", "same", "as", "the", "geometric", "center", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/abst/fiducial/CalibrationFiducialDetector.java#L280-L293
train
lessthanoptimal/BoofCV
main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/SelfCalibrationLinearRotationMulti.java
SelfCalibrationLinearRotationMulti.setConstraints
public void setConstraints( boolean zeroSkew , boolean principlePointOrigin , boolean knownAspect, double aspect ) { if( knownAspect && !zeroSkew ) throw new IllegalArgumentException("If aspect is known then skew must be zero"); this.zeroSkew = zeroSkew; this.principlePointOrigin = principlePointOrigin; this.knownAspectRatio = knownAspect; this.aspectRatio = aspect; notZeros.resize(6); for (int i = 0; i < 6; i++) { notZeros.data[i] = i; } if( principlePointOrigin ) { notZeros.remove(4); notZeros.remove(2); } if( zeroSkew ) { notZeros.remove(1); } }
java
public void setConstraints( boolean zeroSkew , boolean principlePointOrigin , boolean knownAspect, double aspect ) { if( knownAspect && !zeroSkew ) throw new IllegalArgumentException("If aspect is known then skew must be zero"); this.zeroSkew = zeroSkew; this.principlePointOrigin = principlePointOrigin; this.knownAspectRatio = knownAspect; this.aspectRatio = aspect; notZeros.resize(6); for (int i = 0; i < 6; i++) { notZeros.data[i] = i; } if( principlePointOrigin ) { notZeros.remove(4); notZeros.remove(2); } if( zeroSkew ) { notZeros.remove(1); } }
[ "public", "void", "setConstraints", "(", "boolean", "zeroSkew", ",", "boolean", "principlePointOrigin", ",", "boolean", "knownAspect", ",", "double", "aspect", ")", "{", "if", "(", "knownAspect", "&&", "!", "zeroSkew", ")", "throw", "new", "IllegalArgumentExceptio...
Specifies linear constraints Known aspect ratio constraint can only be used if zero skew is also assumped. @param zeroSkew Assume that skew is zero @param principlePointOrigin Principle point is at the origin @param knownAspect that the aspect ratio is known @param aspect If aspect is known then this is the aspect. ratio=fy/fx Ignored otherwise.
[ "Specifies", "linear", "constraints" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/SelfCalibrationLinearRotationMulti.java#L97-L122
train
lessthanoptimal/BoofCV
main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/SelfCalibrationLinearRotationMulti.java
SelfCalibrationLinearRotationMulti.extractReferenceW
void extractReferenceW(DMatrixRMaj nv ) { W0.a11 = nv.data[0]; W0.a12 = W0.a21 = nv.data[1]; W0.a13 = W0.a31 = nv.data[2]; W0.a22 = nv.data[3]; W0.a23 = W0.a32 = nv.data[4]; W0.a33 = nv.data[5]; }
java
void extractReferenceW(DMatrixRMaj nv ) { W0.a11 = nv.data[0]; W0.a12 = W0.a21 = nv.data[1]; W0.a13 = W0.a31 = nv.data[2]; W0.a22 = nv.data[3]; W0.a23 = W0.a32 = nv.data[4]; W0.a33 = nv.data[5]; }
[ "void", "extractReferenceW", "(", "DMatrixRMaj", "nv", ")", "{", "W0", ".", "a11", "=", "nv", ".", "data", "[", "0", "]", ";", "W0", ".", "a12", "=", "W0", ".", "a21", "=", "nv", ".", "data", "[", "1", "]", ";", "W0", ".", "a13", "=", "W0", ...
Extracts calibration for the reference frame
[ "Extracts", "calibration", "for", "the", "reference", "frame" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/SelfCalibrationLinearRotationMulti.java#L231-L238
train
lessthanoptimal/BoofCV
main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/SelfCalibrationLinearRotationMulti.java
SelfCalibrationLinearRotationMulti.convertW
void convertW( Homography2D_F64 w , CameraPinhole c ) { // inv(w) = K*K' tmp.set(w); CommonOps_DDF3.divide(tmp,tmp.a33); CommonOps_DDF3.cholU(tmp); CommonOps_DDF3.invert(tmp,K); CommonOps_DDF3.divide(K,K.a33); c.fx = K.a11; c.fy = knownAspectRatio ? (K.a22 + c.fx*aspectRatio)/2.0 : K.a22; c.skew = zeroSkew ? 0 : K.a12; c.cx = principlePointOrigin ? 0 : K.a13; c.cy = principlePointOrigin ? 0 : K.a23; }
java
void convertW( Homography2D_F64 w , CameraPinhole c ) { // inv(w) = K*K' tmp.set(w); CommonOps_DDF3.divide(tmp,tmp.a33); CommonOps_DDF3.cholU(tmp); CommonOps_DDF3.invert(tmp,K); CommonOps_DDF3.divide(K,K.a33); c.fx = K.a11; c.fy = knownAspectRatio ? (K.a22 + c.fx*aspectRatio)/2.0 : K.a22; c.skew = zeroSkew ? 0 : K.a12; c.cx = principlePointOrigin ? 0 : K.a13; c.cy = principlePointOrigin ? 0 : K.a23; }
[ "void", "convertW", "(", "Homography2D_F64", "w", ",", "CameraPinhole", "c", ")", "{", "// inv(w) = K*K'", "tmp", ".", "set", "(", "w", ")", ";", "CommonOps_DDF3", ".", "divide", "(", "tmp", ",", "tmp", ".", "a33", ")", ";", "CommonOps_DDF3", ".", "cholU...
Converts W into a pinhole camera model by finding the cholesky decomposition
[ "Converts", "W", "into", "a", "pinhole", "camera", "model", "by", "finding", "the", "cholesky", "decomposition" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/SelfCalibrationLinearRotationMulti.java#L245-L258
train
lessthanoptimal/BoofCV
main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/SelfCalibrationLinearRotationMulti.java
SelfCalibrationLinearRotationMulti.extractCalibration
void extractCalibration( Homography2D_F64 Hinv , CameraPinhole c ) { CommonOps_DDF3.multTransA(Hinv,W0,tmp); CommonOps_DDF3.mult(tmp,Hinv,Wi); convertW(Wi,c); }
java
void extractCalibration( Homography2D_F64 Hinv , CameraPinhole c ) { CommonOps_DDF3.multTransA(Hinv,W0,tmp); CommonOps_DDF3.mult(tmp,Hinv,Wi); convertW(Wi,c); }
[ "void", "extractCalibration", "(", "Homography2D_F64", "Hinv", ",", "CameraPinhole", "c", ")", "{", "CommonOps_DDF3", ".", "multTransA", "(", "Hinv", ",", "W0", ",", "tmp", ")", ";", "CommonOps_DDF3", ".", "mult", "(", "tmp", ",", "Hinv", ",", "Wi", ")", ...
Extracts calibration for the non-reference frames w = H^-T*w*H^-1
[ "Extracts", "calibration", "for", "the", "non", "-", "reference", "frames" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/SelfCalibrationLinearRotationMulti.java#L265-L270
train
lessthanoptimal/BoofCV
main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/SelfCalibrationLinearRotationMulti.java
SelfCalibrationLinearRotationMulti.computeInverseH
public boolean computeInverseH(List<Homography2D_F64> homography0toI) { listHInv.reset(); int N = homography0toI.size(); for (int i = 0; i < N; i++) { Homography2D_F64 H = homography0toI.get(i); Homography2D_F64 Hinv = listHInv.grow(); // Ensure the determinant is one double d = CommonOps_DDF3.det(H); if( d < 0 ) CommonOps_DDF3.divide(H,-Math.pow(-d,1.0/3),Hinv); else CommonOps_DDF3.divide(H,Math.pow(d,1.0/3),Hinv); // Now invert the matrix if( !CommonOps_DDF3.invert(Hinv,Hinv) ) { return false; } } return true; }
java
public boolean computeInverseH(List<Homography2D_F64> homography0toI) { listHInv.reset(); int N = homography0toI.size(); for (int i = 0; i < N; i++) { Homography2D_F64 H = homography0toI.get(i); Homography2D_F64 Hinv = listHInv.grow(); // Ensure the determinant is one double d = CommonOps_DDF3.det(H); if( d < 0 ) CommonOps_DDF3.divide(H,-Math.pow(-d,1.0/3),Hinv); else CommonOps_DDF3.divide(H,Math.pow(d,1.0/3),Hinv); // Now invert the matrix if( !CommonOps_DDF3.invert(Hinv,Hinv) ) { return false; } } return true; }
[ "public", "boolean", "computeInverseH", "(", "List", "<", "Homography2D_F64", ">", "homography0toI", ")", "{", "listHInv", ".", "reset", "(", ")", ";", "int", "N", "=", "homography0toI", ".", "size", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";"...
Ensures the determinant is one then inverts the homogrpahy
[ "Ensures", "the", "determinant", "is", "one", "then", "inverts", "the", "homogrpahy" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/SelfCalibrationLinearRotationMulti.java#L275-L295
train
lessthanoptimal/BoofCV
integration/boofcv-android/src/main/java/boofcv/android/camera2/SimpleCamera2Activity.java
SimpleCamera2Activity.startCameraTexture
protected void startCameraTexture( TextureView view ) { if( verbose ) Log.i(TAG,"startCamera(TextureView="+(view!=null)+")"); this.mTextureView = view; this.mView = null; this.mTextureView.setSurfaceTextureListener(mSurfaceTextureListener); }
java
protected void startCameraTexture( TextureView view ) { if( verbose ) Log.i(TAG,"startCamera(TextureView="+(view!=null)+")"); this.mTextureView = view; this.mView = null; this.mTextureView.setSurfaceTextureListener(mSurfaceTextureListener); }
[ "protected", "void", "startCameraTexture", "(", "TextureView", "view", ")", "{", "if", "(", "verbose", ")", "Log", ".", "i", "(", "TAG", ",", "\"startCamera(TextureView=\"", "+", "(", "view", "!=", "null", ")", "+", "\")\"", ")", ";", "this", ".", "mText...
After this function is called the camera will be start. It might not start immediately and there can be a delay. @param view The view the camera is displayed inside or null if not displayed
[ "After", "this", "function", "is", "called", "the", "camera", "will", "be", "start", ".", "It", "might", "not", "start", "immediately", "and", "there", "can", "be", "a", "delay", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-android/src/main/java/boofcv/android/camera2/SimpleCamera2Activity.java#L125-L131
train
lessthanoptimal/BoofCV
integration/boofcv-android/src/main/java/boofcv/android/camera2/SimpleCamera2Activity.java
SimpleCamera2Activity.configureCamera
protected void configureCamera( CameraDevice device , CameraCharacteristics characteristics, CaptureRequest.Builder captureRequestBuilder ) { if( verbose ) Log.i(TAG,"configureCamera() default function"); captureRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_VIDEO); captureRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON); }
java
protected void configureCamera( CameraDevice device , CameraCharacteristics characteristics, CaptureRequest.Builder captureRequestBuilder ) { if( verbose ) Log.i(TAG,"configureCamera() default function"); captureRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_VIDEO); captureRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON); }
[ "protected", "void", "configureCamera", "(", "CameraDevice", "device", ",", "CameraCharacteristics", "characteristics", ",", "CaptureRequest", ".", "Builder", "captureRequestBuilder", ")", "{", "if", "(", "verbose", ")", "Log", ".", "i", "(", "TAG", ",", "\"config...
Override to do custom configuration of the camera's settings. By default the camera is put into auto mode. @param device The camera being configured @param characteristics Used to get information on the device @param captureRequestBuilder used to configure the camera
[ "Override", "to", "do", "custom", "configuration", "of", "the", "camera", "s", "settings", ".", "By", "default", "the", "camera", "is", "put", "into", "auto", "mode", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-android/src/main/java/boofcv/android/camera2/SimpleCamera2Activity.java#L308-L315
train
lessthanoptimal/BoofCV
integration/boofcv-android/src/main/java/boofcv/android/camera2/SimpleCamera2Activity.java
SimpleCamera2Activity.selectCamera
protected boolean selectCamera( String id , CameraCharacteristics characteristics ) { if( verbose ) Log.i(TAG,"selectCamera() default function"); Integer facing = characteristics.get(CameraCharacteristics.LENS_FACING); return facing == null || facing != CameraCharacteristics.LENS_FACING_FRONT; }
java
protected boolean selectCamera( String id , CameraCharacteristics characteristics ) { if( verbose ) Log.i(TAG,"selectCamera() default function"); Integer facing = characteristics.get(CameraCharacteristics.LENS_FACING); return facing == null || facing != CameraCharacteristics.LENS_FACING_FRONT; }
[ "protected", "boolean", "selectCamera", "(", "String", "id", ",", "CameraCharacteristics", "characteristics", ")", "{", "if", "(", "verbose", ")", "Log", ".", "i", "(", "TAG", ",", "\"selectCamera() default function\"", ")", ";", "Integer", "facing", "=", "chara...
By default this will select the backfacing camera. override to change the camera it selects.
[ "By", "default", "this", "will", "select", "the", "backfacing", "camera", ".", "override", "to", "change", "the", "camera", "it", "selects", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-android/src/main/java/boofcv/android/camera2/SimpleCamera2Activity.java#L320-L325
train
lessthanoptimal/BoofCV
integration/boofcv-android/src/main/java/boofcv/android/camera2/SimpleCamera2Activity.java
SimpleCamera2Activity.reopenCameraAtResolution
protected void reopenCameraAtResolution(int cameraWidth, int cameraHeight) { if (Looper.getMainLooper().getThread() != Thread.currentThread()) { throw new RuntimeException("Attempted to reopenCameraAtResolution main looper thread!"); } boolean releaseLock = true; open.mLock.lock(); try { if (verbose) Log.i(TAG, "Reopening camera is null == " + (open.mCameraDevice == null)+" state="+open.state+ " activity="+getClass().getSimpleName()); if( open.state != CameraState.OPEN ) throw new RuntimeException("BUG! Attempted to re-open camera when not open"); if (null == open. mCameraDevice) { throw new RuntimeException("Can't re-open a closed camera"); } closePreviewSession(); open.mCameraSize = null; firstFrame = true; CameraManager manager = (CameraManager) getSystemService(Context.CAMERA_SERVICE); if (manager == null) throw new RuntimeException("Null camera manager"); try { open.mPreviewReader = ImageReader.newInstance( cameraWidth, cameraHeight, ImageFormat.YUV_420_888, 2); // Do the processing inside the the handler thread instead of the looper thread to avoid // grinding the UI to a halt open.mPreviewReader.setOnImageAvailableListener(onAvailableListener, mBackgroundHandler); configureTransform(viewWidth, viewHeight); manager.openCamera(open.cameraId, mStateCallback, null); releaseLock = false; } catch (IllegalArgumentException e) { Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show(); finish(); } catch (CameraAccessException e) { e.printStackTrace(); } } finally { if(releaseLock) open.mLock.unlock(); } }
java
protected void reopenCameraAtResolution(int cameraWidth, int cameraHeight) { if (Looper.getMainLooper().getThread() != Thread.currentThread()) { throw new RuntimeException("Attempted to reopenCameraAtResolution main looper thread!"); } boolean releaseLock = true; open.mLock.lock(); try { if (verbose) Log.i(TAG, "Reopening camera is null == " + (open.mCameraDevice == null)+" state="+open.state+ " activity="+getClass().getSimpleName()); if( open.state != CameraState.OPEN ) throw new RuntimeException("BUG! Attempted to re-open camera when not open"); if (null == open. mCameraDevice) { throw new RuntimeException("Can't re-open a closed camera"); } closePreviewSession(); open.mCameraSize = null; firstFrame = true; CameraManager manager = (CameraManager) getSystemService(Context.CAMERA_SERVICE); if (manager == null) throw new RuntimeException("Null camera manager"); try { open.mPreviewReader = ImageReader.newInstance( cameraWidth, cameraHeight, ImageFormat.YUV_420_888, 2); // Do the processing inside the the handler thread instead of the looper thread to avoid // grinding the UI to a halt open.mPreviewReader.setOnImageAvailableListener(onAvailableListener, mBackgroundHandler); configureTransform(viewWidth, viewHeight); manager.openCamera(open.cameraId, mStateCallback, null); releaseLock = false; } catch (IllegalArgumentException e) { Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show(); finish(); } catch (CameraAccessException e) { e.printStackTrace(); } } finally { if(releaseLock) open.mLock.unlock(); } }
[ "protected", "void", "reopenCameraAtResolution", "(", "int", "cameraWidth", ",", "int", "cameraHeight", ")", "{", "if", "(", "Looper", ".", "getMainLooper", "(", ")", ".", "getThread", "(", ")", "!=", "Thread", ".", "currentThread", "(", ")", ")", "{", "th...
Re-opens the camera with the same settings at the specified resolution. It is assumed that you know what you're doing and that this is a valid resolution. WARNING: UNTESTED
[ "Re", "-", "opens", "the", "camera", "with", "the", "same", "settings", "at", "the", "specified", "resolution", ".", "It", "is", "assumed", "that", "you", "know", "what", "you", "re", "doing", "and", "that", "this", "is", "a", "valid", "resolution", "." ...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-android/src/main/java/boofcv/android/camera2/SimpleCamera2Activity.java#L487-L534
train
lessthanoptimal/BoofCV
integration/boofcv-android/src/main/java/boofcv/android/camera2/SimpleCamera2Activity.java
SimpleCamera2Activity.closeCamera
protected boolean closeCamera() { if( verbose ) Log.i(TAG,"closeCamera() activity="+getClass().getSimpleName()); if (Looper.getMainLooper().getThread() != Thread.currentThread()) { throw new RuntimeException("Attempted to close camera not on the main looper thread!"); } boolean closed = false; // if( verbose ) { // StackTraceElement[] trace = new RuntimeException().getStackTrace(); // for (int i = 0; i < Math.min(trace.length, 3); i++) { // System.out.println("[ " + i + " ] = " + trace[i].toString()); // } // } // NOTE: Since open can only be called in the main looper this won't be enough to prevent // it from closing before it opens. That's why open.state exists open.mLock.lock(); try { if( verbose ) Log.i(TAG,"closeCamera: camera="+(open.mCameraDevice==null)+" state="+open.state); closePreviewSession(); // close has been called while trying to open the camera! if( open.state == CameraState.OPENING ) { // If it's in this state that means an asych task is opening the camera. By changing the state // to closing it will not abort that process when the task is called. open.state = CameraState.CLOSING; if( open.mCameraDevice != null ) { throw new RuntimeException("BUG! Camera is opening and should be null until opened"); } } else { if (null != open.mCameraDevice) { closed = true; open.closeCamera(); } open.state = CameraState.CLOSED; open.clearCamera(); } } finally { open.mLock.unlock(); } return closed; }
java
protected boolean closeCamera() { if( verbose ) Log.i(TAG,"closeCamera() activity="+getClass().getSimpleName()); if (Looper.getMainLooper().getThread() != Thread.currentThread()) { throw new RuntimeException("Attempted to close camera not on the main looper thread!"); } boolean closed = false; // if( verbose ) { // StackTraceElement[] trace = new RuntimeException().getStackTrace(); // for (int i = 0; i < Math.min(trace.length, 3); i++) { // System.out.println("[ " + i + " ] = " + trace[i].toString()); // } // } // NOTE: Since open can only be called in the main looper this won't be enough to prevent // it from closing before it opens. That's why open.state exists open.mLock.lock(); try { if( verbose ) Log.i(TAG,"closeCamera: camera="+(open.mCameraDevice==null)+" state="+open.state); closePreviewSession(); // close has been called while trying to open the camera! if( open.state == CameraState.OPENING ) { // If it's in this state that means an asych task is opening the camera. By changing the state // to closing it will not abort that process when the task is called. open.state = CameraState.CLOSING; if( open.mCameraDevice != null ) { throw new RuntimeException("BUG! Camera is opening and should be null until opened"); } } else { if (null != open.mCameraDevice) { closed = true; open.closeCamera(); } open.state = CameraState.CLOSED; open.clearCamera(); } } finally { open.mLock.unlock(); } return closed; }
[ "protected", "boolean", "closeCamera", "(", ")", "{", "if", "(", "verbose", ")", "Log", ".", "i", "(", "TAG", ",", "\"closeCamera() activity=\"", "+", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ")", ";", "if", "(", "Looper", ".", "getMainLoope...
Closes the camera. Returns true if the camera was not already closed and it closed it @return
[ "Closes", "the", "camera", ".", "Returns", "true", "if", "the", "camera", "was", "not", "already", "closed", "and", "it", "closed", "it" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-android/src/main/java/boofcv/android/camera2/SimpleCamera2Activity.java#L540-L583
train
lessthanoptimal/BoofCV
integration/boofcv-android/src/main/java/boofcv/android/camera2/SimpleCamera2Activity.java
SimpleCamera2Activity.startPreview
private void startPreview() { // Sanity check. Parts of this code assume it's on this thread. If it has been put into a handle // that's fine just be careful nothing assumes it's on the main looper if (Looper.getMainLooper().getThread() != Thread.currentThread()) { throw new RuntimeException("Not on main looper! Modify code to remove assumptions"); } if( verbose ) { Log.i(TAG,"startPreview()"); } try { open.mLock.lock(); if (null == open.mCameraDevice || null == open.mCameraSize) { Log.i(TAG," aborting startPreview. Camera not open yet."); return; } closePreviewSession(); open.surfaces = new ArrayList<>(); open.mPreviewRequestBuilder = open.mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW); if( mTextureView != null && mTextureView.isAvailable() ) { SurfaceTexture texture = mTextureView.getSurfaceTexture(); assert texture != null; texture.setDefaultBufferSize(open.mCameraSize.getWidth(), open.mCameraSize.getHeight()); // Display the camera preview into this texture Surface previewSurface = new Surface(texture); open.surfaces.add(previewSurface); open.mPreviewRequestBuilder.addTarget(previewSurface); } // This is where the image for processing is extracted from Surface readerSurface = open.mPreviewReader.getSurface(); open.surfaces.add(readerSurface); open.mPreviewRequestBuilder.addTarget(readerSurface); createCaptureSession(); } catch (CameraAccessException e) { e.printStackTrace(); } finally { open.mLock.unlock(); } }
java
private void startPreview() { // Sanity check. Parts of this code assume it's on this thread. If it has been put into a handle // that's fine just be careful nothing assumes it's on the main looper if (Looper.getMainLooper().getThread() != Thread.currentThread()) { throw new RuntimeException("Not on main looper! Modify code to remove assumptions"); } if( verbose ) { Log.i(TAG,"startPreview()"); } try { open.mLock.lock(); if (null == open.mCameraDevice || null == open.mCameraSize) { Log.i(TAG," aborting startPreview. Camera not open yet."); return; } closePreviewSession(); open.surfaces = new ArrayList<>(); open.mPreviewRequestBuilder = open.mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW); if( mTextureView != null && mTextureView.isAvailable() ) { SurfaceTexture texture = mTextureView.getSurfaceTexture(); assert texture != null; texture.setDefaultBufferSize(open.mCameraSize.getWidth(), open.mCameraSize.getHeight()); // Display the camera preview into this texture Surface previewSurface = new Surface(texture); open.surfaces.add(previewSurface); open.mPreviewRequestBuilder.addTarget(previewSurface); } // This is where the image for processing is extracted from Surface readerSurface = open.mPreviewReader.getSurface(); open.surfaces.add(readerSurface); open.mPreviewRequestBuilder.addTarget(readerSurface); createCaptureSession(); } catch (CameraAccessException e) { e.printStackTrace(); } finally { open.mLock.unlock(); } }
[ "private", "void", "startPreview", "(", ")", "{", "// Sanity check. Parts of this code assume it's on this thread. If it has been put into a handle", "// that's fine just be careful nothing assumes it's on the main looper", "if", "(", "Looper", ".", "getMainLooper", "(", ")", ".", "g...
Start the camera preview.
[ "Start", "the", "camera", "preview", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-android/src/main/java/boofcv/android/camera2/SimpleCamera2Activity.java#L588-L633
train
lessthanoptimal/BoofCV
integration/boofcv-android/src/main/java/boofcv/android/camera2/SimpleCamera2Activity.java
SimpleCamera2Activity.cameraIntrinsicNominal
public void cameraIntrinsicNominal(CameraPinhole intrinsic ) { open.mLock.lock(); try { // This might be called before the camera is open if (open.mCameraCharacterstics != null) { SizeF physicalSize = open.mCameraCharacterstics.get(CameraCharacteristics.SENSOR_INFO_PHYSICAL_SIZE); Rect activeSize = open.mCameraCharacterstics.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE); Size pixelSize = open.mCameraCharacterstics.get(CameraCharacteristics.SENSOR_INFO_PIXEL_ARRAY_SIZE); float[] focalLengths = open.mCameraCharacterstics.get(CameraCharacteristics.LENS_INFO_AVAILABLE_FOCAL_LENGTHS); if (focalLengths != null && focalLengths.length > 0 && physicalSize != null && activeSize != null && pixelSize != null ) { float fl = focalLengths[0]; float widthToPixel = pixelSize.getWidth() / physicalSize.getWidth(); float heightToPixel = pixelSize.getHeight() / physicalSize.getHeight(); float s = open.mCameraSize.getWidth()/(float)activeSize.width(); intrinsic.fx = fl*widthToPixel*s; intrinsic.fy = fl*heightToPixel*s; intrinsic.skew = 0; intrinsic.cx = activeSize.centerX()*s; intrinsic.cy = activeSize.centerY()*s; intrinsic.width = open.mCameraSize.getWidth(); intrinsic.height = open.mCameraSize.getHeight(); return; } } // 60 degrees seems reasonable for a random guess PerspectiveOps.createIntrinsic(open.mCameraSize.getWidth(),open.mCameraSize.getHeight(), UtilAngle.radian(60)); } finally { open.mLock.unlock(); } }
java
public void cameraIntrinsicNominal(CameraPinhole intrinsic ) { open.mLock.lock(); try { // This might be called before the camera is open if (open.mCameraCharacterstics != null) { SizeF physicalSize = open.mCameraCharacterstics.get(CameraCharacteristics.SENSOR_INFO_PHYSICAL_SIZE); Rect activeSize = open.mCameraCharacterstics.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE); Size pixelSize = open.mCameraCharacterstics.get(CameraCharacteristics.SENSOR_INFO_PIXEL_ARRAY_SIZE); float[] focalLengths = open.mCameraCharacterstics.get(CameraCharacteristics.LENS_INFO_AVAILABLE_FOCAL_LENGTHS); if (focalLengths != null && focalLengths.length > 0 && physicalSize != null && activeSize != null && pixelSize != null ) { float fl = focalLengths[0]; float widthToPixel = pixelSize.getWidth() / physicalSize.getWidth(); float heightToPixel = pixelSize.getHeight() / physicalSize.getHeight(); float s = open.mCameraSize.getWidth()/(float)activeSize.width(); intrinsic.fx = fl*widthToPixel*s; intrinsic.fy = fl*heightToPixel*s; intrinsic.skew = 0; intrinsic.cx = activeSize.centerX()*s; intrinsic.cy = activeSize.centerY()*s; intrinsic.width = open.mCameraSize.getWidth(); intrinsic.height = open.mCameraSize.getHeight(); return; } } // 60 degrees seems reasonable for a random guess PerspectiveOps.createIntrinsic(open.mCameraSize.getWidth(),open.mCameraSize.getHeight(), UtilAngle.radian(60)); } finally { open.mLock.unlock(); } }
[ "public", "void", "cameraIntrinsicNominal", "(", "CameraPinhole", "intrinsic", ")", "{", "open", ".", "mLock", ".", "lock", "(", ")", ";", "try", "{", "// This might be called before the camera is open", "if", "(", "open", ".", "mCameraCharacterstics", "!=", "null",...
Returns the camera intrinsic parameters estimated from the physical parameters returned by the camera2 API
[ "Returns", "the", "camera", "intrinsic", "parameters", "estimated", "from", "the", "physical", "parameters", "returned", "by", "the", "camera2", "API" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-android/src/main/java/boofcv/android/camera2/SimpleCamera2Activity.java#L917-L950
train
lessthanoptimal/BoofCV
integration/boofcv-android/src/main/java/boofcv/android/camera2/SimpleCamera2Activity.java
SimpleCamera2Activity.displayDensityAdjusted
private float displayDensityAdjusted() { open.mLock.lock(); try { if (open.mCameraSize == null) return displayMetrics.density; int rotation = getWindowManager().getDefaultDisplay().getRotation(); int screenWidth = (rotation == 0 || rotation == 2) ? displayMetrics.widthPixels : displayMetrics.heightPixels; int cameraWidth = open.mSensorOrientation == 0 || open.mSensorOrientation == 180 ? open.mCameraSize.getWidth() : open.mCameraSize.getHeight(); return displayMetrics.density * cameraWidth / screenWidth; } finally { open.mLock.unlock(); } }
java
private float displayDensityAdjusted() { open.mLock.lock(); try { if (open.mCameraSize == null) return displayMetrics.density; int rotation = getWindowManager().getDefaultDisplay().getRotation(); int screenWidth = (rotation == 0 || rotation == 2) ? displayMetrics.widthPixels : displayMetrics.heightPixels; int cameraWidth = open.mSensorOrientation == 0 || open.mSensorOrientation == 180 ? open.mCameraSize.getWidth() : open.mCameraSize.getHeight(); return displayMetrics.density * cameraWidth / screenWidth; } finally { open.mLock.unlock(); } }
[ "private", "float", "displayDensityAdjusted", "(", ")", "{", "open", ".", "mLock", ".", "lock", "(", ")", ";", "try", "{", "if", "(", "open", ".", "mCameraSize", "==", "null", ")", "return", "displayMetrics", ".", "density", ";", "int", "rotation", "=", ...
Some times the size of a font of stroke needs to be specified in the input image but then gets scaled to image resolution. This compensates for that.
[ "Some", "times", "the", "size", "of", "a", "font", "of", "stroke", "needs", "to", "be", "specified", "in", "the", "input", "image", "but", "then", "gets", "scaled", "to", "image", "resolution", ".", "This", "compensates", "for", "that", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-android/src/main/java/boofcv/android/camera2/SimpleCamera2Activity.java#L1028-L1043
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/factory/feature/disparity/FactoryStereoDisparity.java
FactoryStereoDisparity.regionSparseWta
public static <T extends ImageGray<T>> StereoDisparitySparse<T> regionSparseWta( int minDisparity , int maxDisparity, int regionRadiusX, int regionRadiusY , double maxPerPixelError , double texture , boolean subpixelInterpolation , Class<T> imageType ) { double maxError = (regionRadiusX*2+1)*(regionRadiusY*2+1)*maxPerPixelError; if( imageType == GrayU8.class ) { DisparitySparseSelect<int[]> select; if( subpixelInterpolation) select = selectDisparitySparseSubpixel_S32((int) maxError, texture); else select = selectDisparitySparse_S32((int) maxError, texture); DisparitySparseScoreSadRect<int[],GrayU8> score = scoreDisparitySparseSadRect_U8(minDisparity,maxDisparity, regionRadiusX, regionRadiusY); return new WrapDisparitySparseSadRect(score,select); } else if( imageType == GrayF32.class ) { DisparitySparseSelect<float[]> select; if( subpixelInterpolation ) select = selectDisparitySparseSubpixel_F32((int) maxError, texture); else select = selectDisparitySparse_F32((int) maxError, texture); DisparitySparseScoreSadRect<float[],GrayF32> score = scoreDisparitySparseSadRect_F32(minDisparity,maxDisparity, regionRadiusX, regionRadiusY); return new WrapDisparitySparseSadRect(score,select); } else throw new RuntimeException("Image type not supported: "+imageType.getSimpleName() ); }
java
public static <T extends ImageGray<T>> StereoDisparitySparse<T> regionSparseWta( int minDisparity , int maxDisparity, int regionRadiusX, int regionRadiusY , double maxPerPixelError , double texture , boolean subpixelInterpolation , Class<T> imageType ) { double maxError = (regionRadiusX*2+1)*(regionRadiusY*2+1)*maxPerPixelError; if( imageType == GrayU8.class ) { DisparitySparseSelect<int[]> select; if( subpixelInterpolation) select = selectDisparitySparseSubpixel_S32((int) maxError, texture); else select = selectDisparitySparse_S32((int) maxError, texture); DisparitySparseScoreSadRect<int[],GrayU8> score = scoreDisparitySparseSadRect_U8(minDisparity,maxDisparity, regionRadiusX, regionRadiusY); return new WrapDisparitySparseSadRect(score,select); } else if( imageType == GrayF32.class ) { DisparitySparseSelect<float[]> select; if( subpixelInterpolation ) select = selectDisparitySparseSubpixel_F32((int) maxError, texture); else select = selectDisparitySparse_F32((int) maxError, texture); DisparitySparseScoreSadRect<float[],GrayF32> score = scoreDisparitySparseSadRect_F32(minDisparity,maxDisparity, regionRadiusX, regionRadiusY); return new WrapDisparitySparseSadRect(score,select); } else throw new RuntimeException("Image type not supported: "+imageType.getSimpleName() ); }
[ "public", "static", "<", "T", "extends", "ImageGray", "<", "T", ">", ">", "StereoDisparitySparse", "<", "T", ">", "regionSparseWta", "(", "int", "minDisparity", ",", "int", "maxDisparity", ",", "int", "regionRadiusX", ",", "int", "regionRadiusY", ",", "double"...
WTA algorithms that computes disparity on a sparse per-pixel basis as requested.. @param minDisparity Minimum disparity that it will check. Must be &ge; 0 and &lt; maxDisparity @param maxDisparity Maximum disparity that it will calculate. Must be &gt; 0 @param regionRadiusX Radius of the rectangular region along x-axis. @param regionRadiusY Radius of the rectangular region along y-axis. @param maxPerPixelError Maximum allowed error in a region per pixel. Set to &lt; 0 to disable. @param texture Tolerance for how similar optimal region is to other region. Closer to zero is more tolerant. Try 0.1 @param subpixelInterpolation true to turn on sub-pixel interpolation @param imageType Type of input image. @param <T> Image type @return Sparse disparity algorithm
[ "WTA", "algorithms", "that", "computes", "disparity", "on", "a", "sparse", "per", "-", "pixel", "basis", "as", "requested", ".." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/factory/feature/disparity/FactoryStereoDisparity.java#L241-L275
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d3/direct/FeatureSpatialDiversity_F32.java
FeatureSpatialDiversity_F32.addPoint
public void addPoint( float x , float y , float z ) { norm.grow().set(x/z, y/z); }
java
public void addPoint( float x , float y , float z ) { norm.grow().set(x/z, y/z); }
[ "public", "void", "addPoint", "(", "float", "x", ",", "float", "y", ",", "float", "z", ")", "{", "norm", ".", "grow", "(", ")", ".", "set", "(", "x", "/", "z", ",", "y", "/", "z", ")", ";", "}" ]
Adds the estimated 3D location of a feature.
[ "Adds", "the", "estimated", "3D", "location", "of", "a", "feature", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d3/direct/FeatureSpatialDiversity_F32.java#L50-L52
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d3/direct/FeatureSpatialDiversity_F32.java
FeatureSpatialDiversity_F32.process
public void process() { computeCovarince(); float eigenvalue = smallestEigenvalue(); // eigenvalue is the variance, convert to standard deviation double stdev = Math.sqrt(eigenvalue); // System.out.println("stdev "+stdev+" total "+norm.size()+" mean "+meanX+" "+meanY); // approximate the spread in by doing it along the x-axis. // Really should be along the smallest singular axis double angle0 = Math.atan2(1.0,sigmas*(meanX-stdev)); double angle1 = Math.atan2(1.0,sigmas*(meanX+stdev)); spread = Math.abs(angle1-angle0); }
java
public void process() { computeCovarince(); float eigenvalue = smallestEigenvalue(); // eigenvalue is the variance, convert to standard deviation double stdev = Math.sqrt(eigenvalue); // System.out.println("stdev "+stdev+" total "+norm.size()+" mean "+meanX+" "+meanY); // approximate the spread in by doing it along the x-axis. // Really should be along the smallest singular axis double angle0 = Math.atan2(1.0,sigmas*(meanX-stdev)); double angle1 = Math.atan2(1.0,sigmas*(meanX+stdev)); spread = Math.abs(angle1-angle0); }
[ "public", "void", "process", "(", ")", "{", "computeCovarince", "(", ")", ";", "float", "eigenvalue", "=", "smallestEigenvalue", "(", ")", ";", "// eigenvalue is the variance, convert to standard deviation", "double", "stdev", "=", "Math", ".", "sqrt", "(", "eigenva...
Computes the worst case spread for how features are laid out
[ "Computes", "the", "worst", "case", "spread", "for", "how", "features", "are", "laid", "out" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d3/direct/FeatureSpatialDiversity_F32.java#L57-L72
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/factory/scene/FactoryImageClassifier.java
FactoryImageClassifier.vgg_cifar10
public static ClassifierAndSource vgg_cifar10() { List<String> sources = new ArrayList<>(); sources.add( "http://boofcv.org/notwiki/largefiles/likevgg_cifar10.zip" ); ClassifierAndSource ret = new ClassifierAndSource(); ret.data0 = new ImageClassifierVggCifar10(); ret.data1 = sources; return ret; }
java
public static ClassifierAndSource vgg_cifar10() { List<String> sources = new ArrayList<>(); sources.add( "http://boofcv.org/notwiki/largefiles/likevgg_cifar10.zip" ); ClassifierAndSource ret = new ClassifierAndSource(); ret.data0 = new ImageClassifierVggCifar10(); ret.data1 = sources; return ret; }
[ "public", "static", "ClassifierAndSource", "vgg_cifar10", "(", ")", "{", "List", "<", "String", ">", "sources", "=", "new", "ArrayList", "<>", "(", ")", ";", "sources", ".", "add", "(", "\"http://boofcv.org/notwiki/largefiles/likevgg_cifar10.zip\"", ")", ";", "Cla...
VGG trained on CIFAR10 data @see ImageClassifierVggCifar10 @return The classifier and where to download the model
[ "VGG", "trained", "on", "CIFAR10", "data" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/factory/scene/FactoryImageClassifier.java#L41-L51
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/factory/scene/FactoryImageClassifier.java
FactoryImageClassifier.nin_imagenet
public static ClassifierAndSource nin_imagenet() { List<String> sources = new ArrayList<>(); sources.add( "http://boofcv.org/notwiki/largefiles/nin_imagenet.zip" ); ClassifierAndSource ret = new ClassifierAndSource(); ret.data0 = new ImageClassifierNiNImageNet(); ret.data1 = sources; return ret; }
java
public static ClassifierAndSource nin_imagenet() { List<String> sources = new ArrayList<>(); sources.add( "http://boofcv.org/notwiki/largefiles/nin_imagenet.zip" ); ClassifierAndSource ret = new ClassifierAndSource(); ret.data0 = new ImageClassifierNiNImageNet(); ret.data1 = sources; return ret; }
[ "public", "static", "ClassifierAndSource", "nin_imagenet", "(", ")", "{", "List", "<", "String", ">", "sources", "=", "new", "ArrayList", "<>", "(", ")", ";", "sources", ".", "add", "(", "\"http://boofcv.org/notwiki/largefiles/nin_imagenet.zip\"", ")", ";", "Class...
NIN trained on ImageNet data @see ImageClassifierNiNImageNet @return The classifier and where to download the model
[ "NIN", "trained", "on", "ImageNet", "data" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/factory/scene/FactoryImageClassifier.java#L60-L70
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/JavaRuntimeLauncher.java
JavaRuntimeLauncher.launch
public Exit launch( Class mainClass , String ...args ) { jvmArgs = configureArguments(mainClass,args); try { Runtime rt = Runtime.getRuntime(); Process pr = rt.exec(jvmArgs); // If it exits too quickly it might not get any error messages if it crashes right away // so the work around is to sleep Thread.sleep(500); BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream())); BufferedReader error = new BufferedReader(new InputStreamReader(pr.getErrorStream())); // print the output from the slave if( !monitorSlave(pr, input, error) ) { if( killRequested ) return Exit.REQUESTED; else return Exit.FROZEN; } if( pr.exitValue() != 0 ) { return Exit.RETURN_NOT_ZERO; } else { return Exit.NORMAL; } } catch (IOException | InterruptedException e) { throw new RuntimeException(e); } }
java
public Exit launch( Class mainClass , String ...args ) { jvmArgs = configureArguments(mainClass,args); try { Runtime rt = Runtime.getRuntime(); Process pr = rt.exec(jvmArgs); // If it exits too quickly it might not get any error messages if it crashes right away // so the work around is to sleep Thread.sleep(500); BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream())); BufferedReader error = new BufferedReader(new InputStreamReader(pr.getErrorStream())); // print the output from the slave if( !monitorSlave(pr, input, error) ) { if( killRequested ) return Exit.REQUESTED; else return Exit.FROZEN; } if( pr.exitValue() != 0 ) { return Exit.RETURN_NOT_ZERO; } else { return Exit.NORMAL; } } catch (IOException | InterruptedException e) { throw new RuntimeException(e); } }
[ "public", "Exit", "launch", "(", "Class", "mainClass", ",", "String", "...", "args", ")", "{", "jvmArgs", "=", "configureArguments", "(", "mainClass", ",", "args", ")", ";", "try", "{", "Runtime", "rt", "=", "Runtime", ".", "getRuntime", "(", ")", ";", ...
Launches the class with the provided arguments. Blocks until the process stops. @param mainClass Class @param args it's arguments @return true if successful or false if it ended on error
[ "Launches", "the", "class", "with", "the", "provided", "arguments", ".", "Blocks", "until", "the", "process", "stops", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/JavaRuntimeLauncher.java#L106-L137
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/JavaRuntimeLauncher.java
JavaRuntimeLauncher.monitorSlave
private boolean monitorSlave(Process pr, BufferedReader input, BufferedReader error) throws IOException, InterruptedException { // flush the input buffer System.in.skip(System.in.available()); // If the total amount of time allocated to the slave exceeds the maximum number of trials multiplied // by the maximum runtime plus some fudge factor the slave is declared as frozen boolean frozen = false; long startTime = System.currentTimeMillis(); long lastAliveMessage = startTime; for(;;) { while( System.in.available() > 0 ) { if( System.in.read() == 'q' ) { System.out.println("User requested for the application to quit by pressing 'q'"); System.exit(0); } } synchronized (streamLock) { printBuffer(error, printErr); } if( input.ready() ) { synchronized (streamLock) { printBuffer(input, printOut); } } else { Thread.sleep(500); } try { // exit value throws an exception is the process has yet to stop pr.exitValue(); break; } catch( IllegalThreadStateException e) { if( killRequested ) { pr.destroy(); break; } // check to see if the process is frozen if(frozenTime > 0 && System.currentTimeMillis() - startTime > frozenTime ) { pr.destroy(); // kill the process frozen = true; break; } // let everyone know its still alive if( System.currentTimeMillis() - lastAliveMessage > 60000 ) { System.out.println("\nMaster is still alive: "+new Date()+" Press 'q' and enter to quit."); lastAliveMessage = System.currentTimeMillis(); } } } synchronized (streamLock) { printBuffer(error, printErr); printBuffer(input, printOut); } durationMilli = System.currentTimeMillis()-startTime; return !frozen && !killRequested; }
java
private boolean monitorSlave(Process pr, BufferedReader input, BufferedReader error) throws IOException, InterruptedException { // flush the input buffer System.in.skip(System.in.available()); // If the total amount of time allocated to the slave exceeds the maximum number of trials multiplied // by the maximum runtime plus some fudge factor the slave is declared as frozen boolean frozen = false; long startTime = System.currentTimeMillis(); long lastAliveMessage = startTime; for(;;) { while( System.in.available() > 0 ) { if( System.in.read() == 'q' ) { System.out.println("User requested for the application to quit by pressing 'q'"); System.exit(0); } } synchronized (streamLock) { printBuffer(error, printErr); } if( input.ready() ) { synchronized (streamLock) { printBuffer(input, printOut); } } else { Thread.sleep(500); } try { // exit value throws an exception is the process has yet to stop pr.exitValue(); break; } catch( IllegalThreadStateException e) { if( killRequested ) { pr.destroy(); break; } // check to see if the process is frozen if(frozenTime > 0 && System.currentTimeMillis() - startTime > frozenTime ) { pr.destroy(); // kill the process frozen = true; break; } // let everyone know its still alive if( System.currentTimeMillis() - lastAliveMessage > 60000 ) { System.out.println("\nMaster is still alive: "+new Date()+" Press 'q' and enter to quit."); lastAliveMessage = System.currentTimeMillis(); } } } synchronized (streamLock) { printBuffer(error, printErr); printBuffer(input, printOut); } durationMilli = System.currentTimeMillis()-startTime; return !frozen && !killRequested; }
[ "private", "boolean", "monitorSlave", "(", "Process", "pr", ",", "BufferedReader", "input", ",", "BufferedReader", "error", ")", "throws", "IOException", ",", "InterruptedException", "{", "// flush the input buffer", "System", ".", "in", ".", "skip", "(", "System", ...
Prints printOut the standard printOut and error from the slave and checks its health. Exits if the slave has finished or is declared frozen. @return true if successful or false if it was forced to kill the slave because it was frozen
[ "Prints", "printOut", "the", "standard", "printOut", "and", "error", "from", "the", "slave", "and", "checks", "its", "health", ".", "Exits", "if", "the", "slave", "has", "finished", "or", "is", "declared", "frozen", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/JavaRuntimeLauncher.java#L145-L210
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/dense/DescribeDenseHogAlg.java
DescribeDenseHogAlg.computeWeightBlockPixels
protected void computeWeightBlockPixels() { int rows = cellsPerBlockY*pixelsPerCell; int cols = cellsPerBlockX*pixelsPerCell; weights = new double[ rows*cols ]; double offsetRow=0,offsetCol=0; int radiusRow=rows/2,radiusCol=cols/2; if( rows%2 == 0 ) { offsetRow = 0.5; } if( cols%2 == 0 ) { offsetCol = 0.5; } // use linear seperability of a Gaussian to make computation easier // sigma is 1/2 the width along each axis int index = 0; for (int row = 0; row < rows; row++) { double drow = row-radiusRow+offsetRow; double pdfRow = UtilGaussian.computePDF(0, radiusRow, drow); for (int col = 0; col < cols; col++) { double dcol = col-radiusCol+offsetCol; double pdfCol = UtilGaussian.computePDF(0, radiusCol, dcol); weights[index++] = pdfCol*pdfRow; } } // normalize so that the largest value is 1.0 double max = 0; for (int i = 0; i < weights.length; i++) { if( weights[i] > max ) { max = weights[i]; } } for (int i = 0; i < weights.length; i++) { weights[i] /= max; } }
java
protected void computeWeightBlockPixels() { int rows = cellsPerBlockY*pixelsPerCell; int cols = cellsPerBlockX*pixelsPerCell; weights = new double[ rows*cols ]; double offsetRow=0,offsetCol=0; int radiusRow=rows/2,radiusCol=cols/2; if( rows%2 == 0 ) { offsetRow = 0.5; } if( cols%2 == 0 ) { offsetCol = 0.5; } // use linear seperability of a Gaussian to make computation easier // sigma is 1/2 the width along each axis int index = 0; for (int row = 0; row < rows; row++) { double drow = row-radiusRow+offsetRow; double pdfRow = UtilGaussian.computePDF(0, radiusRow, drow); for (int col = 0; col < cols; col++) { double dcol = col-radiusCol+offsetCol; double pdfCol = UtilGaussian.computePDF(0, radiusCol, dcol); weights[index++] = pdfCol*pdfRow; } } // normalize so that the largest value is 1.0 double max = 0; for (int i = 0; i < weights.length; i++) { if( weights[i] > max ) { max = weights[i]; } } for (int i = 0; i < weights.length; i++) { weights[i] /= max; } }
[ "protected", "void", "computeWeightBlockPixels", "(", ")", "{", "int", "rows", "=", "cellsPerBlockY", "*", "pixelsPerCell", ";", "int", "cols", "=", "cellsPerBlockX", "*", "pixelsPerCell", ";", "weights", "=", "new", "double", "[", "rows", "*", "cols", "]", ...
Compute gaussian weights applied to each pixel in the block
[ "Compute", "gaussian", "weights", "applied", "to", "each", "pixel", "in", "the", "block" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/dense/DescribeDenseHogAlg.java#L121-L161
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/dense/DescribeDenseHogAlg.java
DescribeDenseHogAlg.computePixelFeatures
private void computePixelFeatures() { for (int y = 0; y < derivX.height; y++) { int pixelIndex = y*derivX.width; int endIndex = pixelIndex+derivX.width; for (; pixelIndex < endIndex; pixelIndex++ ) { float dx = derivX.data[pixelIndex]; float dy = derivY.data[pixelIndex]; // angle from 0 to pi radians orientation.data[pixelIndex] = UtilAngle.atanSafe(dy,dx) + GrlConstants.F_PId2; // gradient magnitude magnitude.data[pixelIndex] = Math.sqrt(dx*dx + dy*dy); } } }
java
private void computePixelFeatures() { for (int y = 0; y < derivX.height; y++) { int pixelIndex = y*derivX.width; int endIndex = pixelIndex+derivX.width; for (; pixelIndex < endIndex; pixelIndex++ ) { float dx = derivX.data[pixelIndex]; float dy = derivY.data[pixelIndex]; // angle from 0 to pi radians orientation.data[pixelIndex] = UtilAngle.atanSafe(dy,dx) + GrlConstants.F_PId2; // gradient magnitude magnitude.data[pixelIndex] = Math.sqrt(dx*dx + dy*dy); } } }
[ "private", "void", "computePixelFeatures", "(", ")", "{", "for", "(", "int", "y", "=", "0", ";", "y", "<", "derivX", ".", "height", ";", "y", "++", ")", "{", "int", "pixelIndex", "=", "y", "*", "derivX", ".", "width", ";", "int", "endIndex", "=", ...
Computes the orientation and magnitude of each pixel
[ "Computes", "the", "orientation", "and", "magnitude", "of", "each", "pixel" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/dense/DescribeDenseHogAlg.java#L179-L193
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/dense/DescribeDenseHogAlg.java
DescribeDenseHogAlg.addToHistogram
void addToHistogram(int cellX, int cellY, int orientationIndex, double magnitude) { // see if it's being applied to a valid cell in the histogram if( cellX < 0 || cellX >= cellsPerBlockX) return; if( cellY < 0 || cellY >= cellsPerBlockY) return; int index = (cellY*cellsPerBlockX + cellX)*orientationBins + orientationIndex; histogram[index] += magnitude; }
java
void addToHistogram(int cellX, int cellY, int orientationIndex, double magnitude) { // see if it's being applied to a valid cell in the histogram if( cellX < 0 || cellX >= cellsPerBlockX) return; if( cellY < 0 || cellY >= cellsPerBlockY) return; int index = (cellY*cellsPerBlockX + cellX)*orientationBins + orientationIndex; histogram[index] += magnitude; }
[ "void", "addToHistogram", "(", "int", "cellX", ",", "int", "cellY", ",", "int", "orientationIndex", ",", "double", "magnitude", ")", "{", "// see if it's being applied to a valid cell in the histogram", "if", "(", "cellX", "<", "0", "||", "cellX", ">=", "cellsPerBlo...
Adds the magnitude to the histogram at the specified cell and orientation @param cellX cell coordinate @param cellY cell coordinate @param orientationIndex orientation coordinate @param magnitude edge magnitude
[ "Adds", "the", "magnitude", "to", "the", "histogram", "at", "the", "specified", "cell", "and", "orientation" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/dense/DescribeDenseHogAlg.java#L330-L339
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/interpolate/array/Interpolate1D_F32.java
Interpolate1D_F32.setInput
public void setInput(float x[], float y[], int size) { if (x.length < size || y.length < size) { throw new IllegalArgumentException("Arrays too small for size."); } if (size < M) { throw new IllegalArgumentException("Not enough data points for M"); } this.x = x; this.y = y; this.size = size; this.dj = Math.min(1, (int) Math.pow(size, 0.25)); ascend = x[size - 1] >= x[0]; }
java
public void setInput(float x[], float y[], int size) { if (x.length < size || y.length < size) { throw new IllegalArgumentException("Arrays too small for size."); } if (size < M) { throw new IllegalArgumentException("Not enough data points for M"); } this.x = x; this.y = y; this.size = size; this.dj = Math.min(1, (int) Math.pow(size, 0.25)); ascend = x[size - 1] >= x[0]; }
[ "public", "void", "setInput", "(", "float", "x", "[", "]", ",", "float", "y", "[", "]", ",", "int", "size", ")", "{", "if", "(", "x", ".", "length", "<", "size", "||", "y", ".", "length", "<", "size", ")", "{", "throw", "new", "IllegalArgumentExc...
Sets the data that is being interpolated. @param x Where the points are sample at. Not modifed. Reference saved. @param y The value at the sample points. Not modifed. Reference saved. @param size The number of points used.
[ "Sets", "the", "data", "that", "is", "being", "interpolated", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/interpolate/array/Interpolate1D_F32.java#L80-L93
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/interpolate/array/Interpolate1D_F32.java
Interpolate1D_F32.process
public float process(float testX) { if (doHunt) { hunt(testX); } else { bisectionSearch(testX, 0, size - 1); } return compute(testX); }
java
public float process(float testX) { if (doHunt) { hunt(testX); } else { bisectionSearch(testX, 0, size - 1); } return compute(testX); }
[ "public", "float", "process", "(", "float", "testX", ")", "{", "if", "(", "doHunt", ")", "{", "hunt", "(", "testX", ")", ";", "}", "else", "{", "bisectionSearch", "(", "testX", ",", "0", ",", "size", "-", "1", ")", ";", "}", "return", "compute", ...
Performs interpolation at the sample point. @param testX Where the interpolated value is done at. @return The interpolated value at sampleX.
[ "Performs", "interpolation", "at", "the", "sample", "point", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/interpolate/array/Interpolate1D_F32.java#L101-L109
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/interpolate/array/Interpolate1D_F32.java
Interpolate1D_F32.hunt
protected void hunt(float val) { int lowerLimit = center; int upperLimit; int inc = 1; if (val >= x[lowerLimit] && ascend) { // hunt up for (; ; ) { upperLimit = lowerLimit + inc; // see if it is outside the table if (upperLimit >= size - 1) { upperLimit = size - 1; break; } else if (val < x[upperLimit] && ascend) { break; } else { lowerLimit = upperLimit; inc += inc; } } } else { // hunt down upperLimit = lowerLimit; for (; ; ) { lowerLimit = lowerLimit - inc; if (lowerLimit <= 0) { lowerLimit = 0; break; } else if (val >= x[lowerLimit] && ascend) { break; } else { upperLimit = lowerLimit; inc += inc; } } } bisectionSearch(val, lowerLimit, upperLimit); }
java
protected void hunt(float val) { int lowerLimit = center; int upperLimit; int inc = 1; if (val >= x[lowerLimit] && ascend) { // hunt up for (; ; ) { upperLimit = lowerLimit + inc; // see if it is outside the table if (upperLimit >= size - 1) { upperLimit = size - 1; break; } else if (val < x[upperLimit] && ascend) { break; } else { lowerLimit = upperLimit; inc += inc; } } } else { // hunt down upperLimit = lowerLimit; for (; ; ) { lowerLimit = lowerLimit - inc; if (lowerLimit <= 0) { lowerLimit = 0; break; } else if (val >= x[lowerLimit] && ascend) { break; } else { upperLimit = lowerLimit; inc += inc; } } } bisectionSearch(val, lowerLimit, upperLimit); }
[ "protected", "void", "hunt", "(", "float", "val", ")", "{", "int", "lowerLimit", "=", "center", ";", "int", "upperLimit", ";", "int", "inc", "=", "1", ";", "if", "(", "val", ">=", "x", "[", "lowerLimit", "]", "&&", "ascend", ")", "{", "// hunt up", ...
To speed up finding the appropriate indexes to use in the interpolation it can use its previous results to search a smaller region than it would otherwise. @param val The value that is to be interpolated.
[ "To", "speed", "up", "finding", "the", "appropriate", "indexes", "to", "use", "in", "the", "interpolation", "it", "can", "use", "its", "previous", "results", "to", "search", "a", "smaller", "region", "than", "it", "would", "otherwise", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/interpolate/array/Interpolate1D_F32.java#L150-L188
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/filter/derivative/impl/GradientSobel_Naive.java
GradientSobel_Naive.process
public static void process( GrayI orig, GrayI derivX, GrayI derivY) { final int width = orig.getWidth(); final int height = orig.getHeight(); for (int y = 1; y < height - 1; y++) { for (int x = 1; x < width - 1; x++) { int dy = -(orig.get(x - 1, y - 1) + 2 * orig.get(x, y - 1) + orig.get(x + 1, y - 1)); dy += (orig.get(x - 1, y + 1) + 2 * orig.get(x, y + 1) + orig.get(x + 1, y + 1)); int dx = -(orig.get(x - 1, y - 1) + 2 * orig.get(x - 1, y) + orig.get(x - 1, y + 1)); dx += (orig.get(x + 1, y - 1) + 2 * orig.get(x + 1, y) + orig.get(x + 1, y + 1)); derivX.set(x, y, dx); derivY.set(x, y, dy); } } }
java
public static void process( GrayI orig, GrayI derivX, GrayI derivY) { final int width = orig.getWidth(); final int height = orig.getHeight(); for (int y = 1; y < height - 1; y++) { for (int x = 1; x < width - 1; x++) { int dy = -(orig.get(x - 1, y - 1) + 2 * orig.get(x, y - 1) + orig.get(x + 1, y - 1)); dy += (orig.get(x - 1, y + 1) + 2 * orig.get(x, y + 1) + orig.get(x + 1, y + 1)); int dx = -(orig.get(x - 1, y - 1) + 2 * orig.get(x - 1, y) + orig.get(x - 1, y + 1)); dx += (orig.get(x + 1, y - 1) + 2 * orig.get(x + 1, y) + orig.get(x + 1, y + 1)); derivX.set(x, y, dx); derivY.set(x, y, dy); } } }
[ "public", "static", "void", "process", "(", "GrayI", "orig", ",", "GrayI", "derivX", ",", "GrayI", "derivY", ")", "{", "final", "int", "width", "=", "orig", ".", "getWidth", "(", ")", ";", "final", "int", "height", "=", "orig", ".", "getHeight", "(", ...
Computes the derivative of 'orig' along the x and y axes
[ "Computes", "the", "derivative", "of", "orig", "along", "the", "x", "and", "y", "axes" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/derivative/impl/GradientSobel_Naive.java#L42-L63
train
lessthanoptimal/BoofCV
examples/src/main/java/boofcv/examples/segmentation/ExampleSegmentSuperpixels.java
ExampleSegmentSuperpixels.performSegmentation
public static <T extends ImageBase<T>> void performSegmentation( ImageSuperpixels<T> alg , T color ) { // Segmentation often works better after blurring the image. Reduces high frequency image components which // can cause over segmentation GBlurImageOps.gaussian(color, color, 0.5, -1, null); // Storage for segmented image. Each pixel will be assigned a label from 0 to N-1, where N is the number // of segments in the image GrayS32 pixelToSegment = new GrayS32(color.width,color.height); // Segmentation magic happens here alg.segment(color,pixelToSegment); // Displays the results visualize(pixelToSegment,color,alg.getTotalSuperpixels()); }
java
public static <T extends ImageBase<T>> void performSegmentation( ImageSuperpixels<T> alg , T color ) { // Segmentation often works better after blurring the image. Reduces high frequency image components which // can cause over segmentation GBlurImageOps.gaussian(color, color, 0.5, -1, null); // Storage for segmented image. Each pixel will be assigned a label from 0 to N-1, where N is the number // of segments in the image GrayS32 pixelToSegment = new GrayS32(color.width,color.height); // Segmentation magic happens here alg.segment(color,pixelToSegment); // Displays the results visualize(pixelToSegment,color,alg.getTotalSuperpixels()); }
[ "public", "static", "<", "T", "extends", "ImageBase", "<", "T", ">", ">", "void", "performSegmentation", "(", "ImageSuperpixels", "<", "T", ">", "alg", ",", "T", "color", ")", "{", "// Segmentation often works better after blurring the image. Reduces high frequency ima...
Segments and visualizes the image
[ "Segments", "and", "visualizes", "the", "image" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/segmentation/ExampleSegmentSuperpixels.java#L53-L69
train
lessthanoptimal/BoofCV
examples/src/main/java/boofcv/examples/segmentation/ExampleSegmentSuperpixels.java
ExampleSegmentSuperpixels.visualize
public static <T extends ImageBase<T>> void visualize(GrayS32 pixelToRegion , T color , int numSegments ) { // Computes the mean color inside each region ImageType<T> type = color.getImageType(); ComputeRegionMeanColor<T> colorize = FactorySegmentationAlg.regionMeanColor(type); FastQueue<float[]> segmentColor = new ColorQueue_F32(type.getNumBands()); segmentColor.resize(numSegments); GrowQueue_I32 regionMemberCount = new GrowQueue_I32(); regionMemberCount.resize(numSegments); ImageSegmentationOps.countRegionPixels(pixelToRegion, numSegments, regionMemberCount.data); colorize.process(color,pixelToRegion,regionMemberCount,segmentColor); // Draw each region using their average color BufferedImage outColor = VisualizeRegions.regionsColor(pixelToRegion,segmentColor,null); // Draw each region by assigning it a random color BufferedImage outSegments = VisualizeRegions.regions(pixelToRegion, numSegments, null); // Make region edges appear red BufferedImage outBorder = new BufferedImage(color.width,color.height,BufferedImage.TYPE_INT_RGB); ConvertBufferedImage.convertTo(color, outBorder, true); VisualizeRegions.regionBorders(pixelToRegion,0xFF0000,outBorder); // Show the visualization results ListDisplayPanel gui = new ListDisplayPanel(); gui.addImage(outColor,"Color of Segments"); gui.addImage(outBorder, "Region Borders"); gui.addImage(outSegments, "Regions"); ShowImages.showWindow(gui,"Superpixels", true); }
java
public static <T extends ImageBase<T>> void visualize(GrayS32 pixelToRegion , T color , int numSegments ) { // Computes the mean color inside each region ImageType<T> type = color.getImageType(); ComputeRegionMeanColor<T> colorize = FactorySegmentationAlg.regionMeanColor(type); FastQueue<float[]> segmentColor = new ColorQueue_F32(type.getNumBands()); segmentColor.resize(numSegments); GrowQueue_I32 regionMemberCount = new GrowQueue_I32(); regionMemberCount.resize(numSegments); ImageSegmentationOps.countRegionPixels(pixelToRegion, numSegments, regionMemberCount.data); colorize.process(color,pixelToRegion,regionMemberCount,segmentColor); // Draw each region using their average color BufferedImage outColor = VisualizeRegions.regionsColor(pixelToRegion,segmentColor,null); // Draw each region by assigning it a random color BufferedImage outSegments = VisualizeRegions.regions(pixelToRegion, numSegments, null); // Make region edges appear red BufferedImage outBorder = new BufferedImage(color.width,color.height,BufferedImage.TYPE_INT_RGB); ConvertBufferedImage.convertTo(color, outBorder, true); VisualizeRegions.regionBorders(pixelToRegion,0xFF0000,outBorder); // Show the visualization results ListDisplayPanel gui = new ListDisplayPanel(); gui.addImage(outColor,"Color of Segments"); gui.addImage(outBorder, "Region Borders"); gui.addImage(outSegments, "Regions"); ShowImages.showWindow(gui,"Superpixels", true); }
[ "public", "static", "<", "T", "extends", "ImageBase", "<", "T", ">", ">", "void", "visualize", "(", "GrayS32", "pixelToRegion", ",", "T", "color", ",", "int", "numSegments", ")", "{", "// Computes the mean color inside each region", "ImageType", "<", "T", ">", ...
Visualizes results three ways. 1) Colorized segmented image where each region is given a random color. 2) Each pixel is assigned the mean color through out the region. 3) Black pixels represent the border between regions.
[ "Visualizes", "results", "three", "ways", ".", "1", ")", "Colorized", "segmented", "image", "where", "each", "region", "is", "given", "a", "random", "color", ".", "2", ")", "Each", "pixel", "is", "assigned", "the", "mean", "color", "through", "out", "the",...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/segmentation/ExampleSegmentSuperpixels.java#L76-L108
train
lessthanoptimal/BoofCV
examples/src/main/java/boofcv/examples/stereo/ExampleStereoDisparity.java
ExampleStereoDisparity.denseDisparity
public static GrayU8 denseDisparity(GrayU8 rectLeft , GrayU8 rectRight , int regionSize, int minDisparity , int maxDisparity ) { // A slower but more accuracy algorithm is selected // All of these parameters should be turned StereoDisparity<GrayU8,GrayU8> disparityAlg = FactoryStereoDisparity.regionWta(DisparityAlgorithms.RECT_FIVE, minDisparity, maxDisparity, regionSize, regionSize, 25, 1, 0.2, GrayU8.class); // process and return the results disparityAlg.process(rectLeft,rectRight); return disparityAlg.getDisparity(); }
java
public static GrayU8 denseDisparity(GrayU8 rectLeft , GrayU8 rectRight , int regionSize, int minDisparity , int maxDisparity ) { // A slower but more accuracy algorithm is selected // All of these parameters should be turned StereoDisparity<GrayU8,GrayU8> disparityAlg = FactoryStereoDisparity.regionWta(DisparityAlgorithms.RECT_FIVE, minDisparity, maxDisparity, regionSize, regionSize, 25, 1, 0.2, GrayU8.class); // process and return the results disparityAlg.process(rectLeft,rectRight); return disparityAlg.getDisparity(); }
[ "public", "static", "GrayU8", "denseDisparity", "(", "GrayU8", "rectLeft", ",", "GrayU8", "rectRight", ",", "int", "regionSize", ",", "int", "minDisparity", ",", "int", "maxDisparity", ")", "{", "// A slower but more accuracy algorithm is selected", "// All of these param...
Computes the dense disparity between between two stereo images. The input images must be rectified with lens distortion removed to work! Floating point images are also supported. @param rectLeft Rectified left camera image @param rectRight Rectified right camera image @param regionSize Radius of region being matched @param minDisparity Minimum disparity that is considered @param maxDisparity Maximum disparity that is considered @return Disparity image
[ "Computes", "the", "dense", "disparity", "between", "between", "two", "stereo", "images", ".", "The", "input", "images", "must", "be", "rectified", "with", "lens", "distortion", "removed", "to", "work!", "Floating", "point", "images", "are", "also", "supported",...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/stereo/ExampleStereoDisparity.java#L74-L88
train
lessthanoptimal/BoofCV
examples/src/main/java/boofcv/examples/stereo/ExampleStereoDisparity.java
ExampleStereoDisparity.denseDisparitySubpixel
public static GrayF32 denseDisparitySubpixel(GrayU8 rectLeft , GrayU8 rectRight , int regionSize , int minDisparity , int maxDisparity ) { // A slower but more accuracy algorithm is selected // All of these parameters should be turned StereoDisparity<GrayU8,GrayF32> disparityAlg = FactoryStereoDisparity.regionSubpixelWta(DisparityAlgorithms.RECT_FIVE, minDisparity, maxDisparity, regionSize, regionSize, 25, 1, 0.2, GrayU8.class); // process and return the results disparityAlg.process(rectLeft,rectRight); return disparityAlg.getDisparity(); }
java
public static GrayF32 denseDisparitySubpixel(GrayU8 rectLeft , GrayU8 rectRight , int regionSize , int minDisparity , int maxDisparity ) { // A slower but more accuracy algorithm is selected // All of these parameters should be turned StereoDisparity<GrayU8,GrayF32> disparityAlg = FactoryStereoDisparity.regionSubpixelWta(DisparityAlgorithms.RECT_FIVE, minDisparity, maxDisparity, regionSize, regionSize, 25, 1, 0.2, GrayU8.class); // process and return the results disparityAlg.process(rectLeft,rectRight); return disparityAlg.getDisparity(); }
[ "public", "static", "GrayF32", "denseDisparitySubpixel", "(", "GrayU8", "rectLeft", ",", "GrayU8", "rectRight", ",", "int", "regionSize", ",", "int", "minDisparity", ",", "int", "maxDisparity", ")", "{", "// A slower but more accuracy algorithm is selected", "// All of th...
Same as above, but compute disparity to within sub-pixel accuracy. The difference between the two is more apparent when a 3D point cloud is computed.
[ "Same", "as", "above", "but", "compute", "disparity", "to", "within", "sub", "-", "pixel", "accuracy", ".", "The", "difference", "between", "the", "two", "is", "more", "apparent", "when", "a", "3D", "point", "cloud", "is", "computed", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/stereo/ExampleStereoDisparity.java#L94-L108
train
lessthanoptimal/BoofCV
examples/src/main/java/boofcv/examples/stereo/ExampleStereoDisparity.java
ExampleStereoDisparity.rectify
public static RectifyCalibrated rectify(GrayU8 origLeft , GrayU8 origRight , StereoParameters param , GrayU8 rectLeft , GrayU8 rectRight ) { // Compute rectification RectifyCalibrated rectifyAlg = RectifyImageOps.createCalibrated(); Se3_F64 leftToRight = param.getRightToLeft().invert(null); // original camera calibration matrices DMatrixRMaj K1 = PerspectiveOps.pinholeToMatrix(param.getLeft(), (DMatrixRMaj)null); DMatrixRMaj K2 = PerspectiveOps.pinholeToMatrix(param.getRight(), (DMatrixRMaj)null); rectifyAlg.process(K1,new Se3_F64(),K2,leftToRight); // rectification matrix for each image DMatrixRMaj rect1 = rectifyAlg.getRect1(); DMatrixRMaj rect2 = rectifyAlg.getRect2(); // New calibration matrix, DMatrixRMaj rectK = rectifyAlg.getCalibrationMatrix(); // Adjust the rectification to make the view area more useful RectifyImageOps.allInsideLeft(param.left, rect1, rect2, rectK); // undistorted and rectify images FMatrixRMaj rect1_F32 = new FMatrixRMaj(3,3); FMatrixRMaj rect2_F32 = new FMatrixRMaj(3,3); ConvertMatrixData.convert(rect1, rect1_F32); ConvertMatrixData.convert(rect2, rect2_F32); ImageDistort<GrayU8,GrayU8> imageDistortLeft = RectifyImageOps.rectifyImage(param.getLeft(), rect1_F32, BorderType.SKIP, origLeft.getImageType()); ImageDistort<GrayU8,GrayU8> imageDistortRight = RectifyImageOps.rectifyImage(param.getRight(), rect2_F32, BorderType.SKIP, origRight.getImageType()); imageDistortLeft.apply(origLeft, rectLeft); imageDistortRight.apply(origRight, rectRight); return rectifyAlg; }
java
public static RectifyCalibrated rectify(GrayU8 origLeft , GrayU8 origRight , StereoParameters param , GrayU8 rectLeft , GrayU8 rectRight ) { // Compute rectification RectifyCalibrated rectifyAlg = RectifyImageOps.createCalibrated(); Se3_F64 leftToRight = param.getRightToLeft().invert(null); // original camera calibration matrices DMatrixRMaj K1 = PerspectiveOps.pinholeToMatrix(param.getLeft(), (DMatrixRMaj)null); DMatrixRMaj K2 = PerspectiveOps.pinholeToMatrix(param.getRight(), (DMatrixRMaj)null); rectifyAlg.process(K1,new Se3_F64(),K2,leftToRight); // rectification matrix for each image DMatrixRMaj rect1 = rectifyAlg.getRect1(); DMatrixRMaj rect2 = rectifyAlg.getRect2(); // New calibration matrix, DMatrixRMaj rectK = rectifyAlg.getCalibrationMatrix(); // Adjust the rectification to make the view area more useful RectifyImageOps.allInsideLeft(param.left, rect1, rect2, rectK); // undistorted and rectify images FMatrixRMaj rect1_F32 = new FMatrixRMaj(3,3); FMatrixRMaj rect2_F32 = new FMatrixRMaj(3,3); ConvertMatrixData.convert(rect1, rect1_F32); ConvertMatrixData.convert(rect2, rect2_F32); ImageDistort<GrayU8,GrayU8> imageDistortLeft = RectifyImageOps.rectifyImage(param.getLeft(), rect1_F32, BorderType.SKIP, origLeft.getImageType()); ImageDistort<GrayU8,GrayU8> imageDistortRight = RectifyImageOps.rectifyImage(param.getRight(), rect2_F32, BorderType.SKIP, origRight.getImageType()); imageDistortLeft.apply(origLeft, rectLeft); imageDistortRight.apply(origRight, rectRight); return rectifyAlg; }
[ "public", "static", "RectifyCalibrated", "rectify", "(", "GrayU8", "origLeft", ",", "GrayU8", "origRight", ",", "StereoParameters", "param", ",", "GrayU8", "rectLeft", ",", "GrayU8", "rectRight", ")", "{", "// Compute rectification", "RectifyCalibrated", "rectifyAlg", ...
Rectified the input images using known calibration.
[ "Rectified", "the", "input", "images", "using", "known", "calibration", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/stereo/ExampleStereoDisparity.java#L113-L151
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/color/Histogram_F64.java
Histogram_F64.isRangeSet
public boolean isRangeSet() { for (int i = 0; i < getDimensions(); i++) { if( valueMin[i] == 0 && valueMax[i] == 0 ) { return false; } } return true; }
java
public boolean isRangeSet() { for (int i = 0; i < getDimensions(); i++) { if( valueMin[i] == 0 && valueMax[i] == 0 ) { return false; } } return true; }
[ "public", "boolean", "isRangeSet", "(", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "getDimensions", "(", ")", ";", "i", "++", ")", "{", "if", "(", "valueMin", "[", "i", "]", "==", "0", "&&", "valueMax", "[", "i", "]", "==", "0...
Returns true if the min and max value for each dimension has been set @return true if range has been set
[ "Returns", "true", "if", "the", "min", "and", "max", "value", "for", "each", "dimension", "has", "been", "set" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/color/Histogram_F64.java#L81-L89
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/color/Histogram_F64.java
Histogram_F64.setRange
public void setRange( int dimension , double min , double max ) { valueMin[dimension] = min; valueMax[dimension] = max; }
java
public void setRange( int dimension , double min , double max ) { valueMin[dimension] = min; valueMax[dimension] = max; }
[ "public", "void", "setRange", "(", "int", "dimension", ",", "double", "min", ",", "double", "max", ")", "{", "valueMin", "[", "dimension", "]", "=", "min", ";", "valueMax", "[", "dimension", "]", "=", "max", ";", "}" ]
Specifies the minimum and maximum values for a specific dimension @param dimension Which dimension @param min The minimum value @param max The maximum value
[ "Specifies", "the", "minimum", "and", "maximum", "values", "for", "a", "specific", "dimension" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/color/Histogram_F64.java#L115-L118
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/color/Histogram_F64.java
Histogram_F64.getDimensionIndex
public int getDimensionIndex( int dimension , int value ) { double min = valueMin[dimension]; double max = valueMax[dimension]; double fraction = ((value-min)/(max-min+1.0)); return (int)(fraction*length[dimension]); }
java
public int getDimensionIndex( int dimension , int value ) { double min = valueMin[dimension]; double max = valueMax[dimension]; double fraction = ((value-min)/(max-min+1.0)); return (int)(fraction*length[dimension]); }
[ "public", "int", "getDimensionIndex", "(", "int", "dimension", ",", "int", "value", ")", "{", "double", "min", "=", "valueMin", "[", "dimension", "]", ";", "double", "max", "=", "valueMax", "[", "dimension", "]", ";", "double", "fraction", "=", "(", "(",...
Given a value it returns the corresponding bin index in this histogram for integer values. The discretion is taken in account and 1 is added to the range. @param dimension Which dimension the value belongs to @param value Floating point value between min and max, inclusive. @return The index/bin
[ "Given", "a", "value", "it", "returns", "the", "corresponding", "bin", "index", "in", "this", "histogram", "for", "integer", "values", ".", "The", "discretion", "is", "taken", "in", "account", "and", "1", "is", "added", "to", "the", "range", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/color/Histogram_F64.java#L184-L190
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/color/Histogram_F64.java
Histogram_F64.getIndex
public final int getIndex( int coordinate[] ) { int index = coordinate[0]*strides[0]; for (int i = 1; i < coordinate.length; i++) { index += strides[i]*coordinate[i]; } return index; }
java
public final int getIndex( int coordinate[] ) { int index = coordinate[0]*strides[0]; for (int i = 1; i < coordinate.length; i++) { index += strides[i]*coordinate[i]; } return index; }
[ "public", "final", "int", "getIndex", "(", "int", "coordinate", "[", "]", ")", "{", "int", "index", "=", "coordinate", "[", "0", "]", "*", "strides", "[", "0", "]", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "coordinate", ".", "length"...
For a N-Dimensional histogram it will return the array index for the N-D coordinate @param coordinate N-D coordinate @return index
[ "For", "a", "N", "-", "Dimensional", "histogram", "it", "will", "return", "the", "array", "index", "for", "the", "N", "-", "D", "coordinate" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/color/Histogram_F64.java#L219-L226
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/color/Histogram_F64.java
Histogram_F64.copy
public Histogram_F64 copy() { Histogram_F64 out = newInstance(); System.arraycopy(value,0,out.value,0,length.length); return out; }
java
public Histogram_F64 copy() { Histogram_F64 out = newInstance(); System.arraycopy(value,0,out.value,0,length.length); return out; }
[ "public", "Histogram_F64", "copy", "(", ")", "{", "Histogram_F64", "out", "=", "newInstance", "(", ")", ";", "System", ".", "arraycopy", "(", "value", ",", "0", ",", "out", ".", "value", ",", "0", ",", "length", ".", "length", ")", ";", "return", "ou...
Creates an exact copy of "this" histogram
[ "Creates", "an", "exact", "copy", "of", "this", "histogram" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/color/Histogram_F64.java#L261-L267
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/polygon/RefinePolygonToGrayLine.java
RefinePolygonToGrayLine.refine
@Override public boolean refine(Polygon2D_F64 input, Polygon2D_F64 output) { if( input.size() != output.size()) throw new IllegalArgumentException("Input and output sides do not match. "+input.size()+" "+output.size()); // sanity check input. If it's too small this algorithm won't work if( checkShapeTooSmall(input) ) return false; // see if this work space needs to be resized if( general.length < input.size() ) { general = new LineGeneral2D_F64[input.size() ]; for (int i = 0; i < general.length; i++) { general[i] = new LineGeneral2D_F64(); } } // estimate line equations return optimize(input,output); }
java
@Override public boolean refine(Polygon2D_F64 input, Polygon2D_F64 output) { if( input.size() != output.size()) throw new IllegalArgumentException("Input and output sides do not match. "+input.size()+" "+output.size()); // sanity check input. If it's too small this algorithm won't work if( checkShapeTooSmall(input) ) return false; // see if this work space needs to be resized if( general.length < input.size() ) { general = new LineGeneral2D_F64[input.size() ]; for (int i = 0; i < general.length; i++) { general[i] = new LineGeneral2D_F64(); } } // estimate line equations return optimize(input,output); }
[ "@", "Override", "public", "boolean", "refine", "(", "Polygon2D_F64", "input", ",", "Polygon2D_F64", "output", ")", "{", "if", "(", "input", ".", "size", "(", ")", "!=", "output", ".", "size", "(", ")", ")", "throw", "new", "IllegalArgumentException", "(",...
Refines the fit a polygon by snapping it to the edges. @param input (input) Initial estimate for the polygon. CW or CCW ordering doesn't matter. @param output (output) the fitted polygon
[ "Refines", "the", "fit", "a", "polygon", "by", "snapping", "it", "to", "the", "edges", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/polygon/RefinePolygonToGrayLine.java#L144-L164
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/polygon/RefinePolygonToGrayLine.java
RefinePolygonToGrayLine.checkShapeTooSmall
private boolean checkShapeTooSmall(Polygon2D_F64 input) { // must be longer than the border plus some small fudge factor double minLength = cornerOffset*2 + 2; for (int i = 0; i < input.size(); i++) { int j = (i+1)%input.size(); Point2D_F64 a = input.get(i); Point2D_F64 b = input.get(j); if( a.distance2(b) < minLength*minLength ) return true; } return false; }
java
private boolean checkShapeTooSmall(Polygon2D_F64 input) { // must be longer than the border plus some small fudge factor double minLength = cornerOffset*2 + 2; for (int i = 0; i < input.size(); i++) { int j = (i+1)%input.size(); Point2D_F64 a = input.get(i); Point2D_F64 b = input.get(j); if( a.distance2(b) < minLength*minLength ) return true; } return false; }
[ "private", "boolean", "checkShapeTooSmall", "(", "Polygon2D_F64", "input", ")", "{", "// must be longer than the border plus some small fudge factor", "double", "minLength", "=", "cornerOffset", "*", "2", "+", "2", ";", "for", "(", "int", "i", "=", "0", ";", "i", ...
Looks at the distance between each vertex. If that distance is so small the edge can't be measured the return true. @param input polygon @return true if too small or false if not
[ "Looks", "at", "the", "distance", "between", "each", "vertex", ".", "If", "that", "distance", "is", "so", "small", "the", "edge", "can", "t", "be", "measured", "the", "return", "true", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/polygon/RefinePolygonToGrayLine.java#L172-L184
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/polygon/RefinePolygonToGrayLine.java
RefinePolygonToGrayLine.optimize
protected boolean optimize(Polygon2D_F64 seed , Polygon2D_F64 current ) { previous.set(seed); // pixels squares is faster to compute double convergeTol = convergeTolPixels*convergeTolPixels; // initialize the lines since they are used to check for corner divergence for (int i = 0; i < seed.size(); i++) { int j = (i + 1) % seed.size(); Point2D_F64 a = seed.get(i); Point2D_F64 b = seed.get(j); UtilLine2D_F64.convert(a,b,general[i]); } boolean changed = false; for (int iteration = 0; iteration < maxIterations; iteration++) { // snap each line to the edge independently. Lines will be in local coordinates for (int i = 0; i < previous.size(); i++) { int j = (i + 1) % previous.size(); Point2D_F64 a = previous.get(i); Point2D_F64 b = previous.get(j); before.set(general[i]); boolean failed = false; if( !optimize(a,b,general[i]) ) { failed = true; } else { int k = (i+previous.size()-1) %previous.size(); // see if the corner has diverged if( Intersection2D_F64.intersection(general[k], general[i],tempA) != null && Intersection2D_F64.intersection(general[i], general[j],tempB) != null ) { if( tempA.distance(a) > maxCornerChangePixel || tempB.distance(b) > maxCornerChangePixel ) { failed = true; } } else { failed = true; } } // The line fit failed. Probably because its along the image border. Revert it if( failed ) { general[i].set(before); } else { changed = true; } } // Find the corners of the quadrilateral from the lines if( !UtilShapePolygon.convert(general,current) ) return false; // see if it has converged boolean converged = true; for (int i = 0; i < current.size(); i++) { if( current.get(i).distance2(previous.get(i)) > convergeTol ) { converged = false; break; } } if( converged ) { // System.out.println("Converged early at "+iteration); break; } else { previous.set(current); } } return changed; }
java
protected boolean optimize(Polygon2D_F64 seed , Polygon2D_F64 current ) { previous.set(seed); // pixels squares is faster to compute double convergeTol = convergeTolPixels*convergeTolPixels; // initialize the lines since they are used to check for corner divergence for (int i = 0; i < seed.size(); i++) { int j = (i + 1) % seed.size(); Point2D_F64 a = seed.get(i); Point2D_F64 b = seed.get(j); UtilLine2D_F64.convert(a,b,general[i]); } boolean changed = false; for (int iteration = 0; iteration < maxIterations; iteration++) { // snap each line to the edge independently. Lines will be in local coordinates for (int i = 0; i < previous.size(); i++) { int j = (i + 1) % previous.size(); Point2D_F64 a = previous.get(i); Point2D_F64 b = previous.get(j); before.set(general[i]); boolean failed = false; if( !optimize(a,b,general[i]) ) { failed = true; } else { int k = (i+previous.size()-1) %previous.size(); // see if the corner has diverged if( Intersection2D_F64.intersection(general[k], general[i],tempA) != null && Intersection2D_F64.intersection(general[i], general[j],tempB) != null ) { if( tempA.distance(a) > maxCornerChangePixel || tempB.distance(b) > maxCornerChangePixel ) { failed = true; } } else { failed = true; } } // The line fit failed. Probably because its along the image border. Revert it if( failed ) { general[i].set(before); } else { changed = true; } } // Find the corners of the quadrilateral from the lines if( !UtilShapePolygon.convert(general,current) ) return false; // see if it has converged boolean converged = true; for (int i = 0; i < current.size(); i++) { if( current.get(i).distance2(previous.get(i)) > convergeTol ) { converged = false; break; } } if( converged ) { // System.out.println("Converged early at "+iteration); break; } else { previous.set(current); } } return changed; }
[ "protected", "boolean", "optimize", "(", "Polygon2D_F64", "seed", ",", "Polygon2D_F64", "current", ")", "{", "previous", ".", "set", "(", "seed", ")", ";", "// pixels squares is faster to compute", "double", "convergeTol", "=", "convergeTolPixels", "*", "convergeTolPi...
Refines the initial line estimates using EM. The number of iterations is fixed.
[ "Refines", "the", "initial", "line", "estimates", "using", "EM", ".", "The", "number", "of", "iterations", "is", "fixed", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/polygon/RefinePolygonToGrayLine.java#L189-L261
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/polygon/RefinePolygonToGrayLine.java
RefinePolygonToGrayLine.optimize
protected boolean optimize( Point2D_F64 a , Point2D_F64 b , LineGeneral2D_F64 found ) { computeAdjustedEndPoints(a, b); return snapToEdge.refine(adjA, adjB, found); }
java
protected boolean optimize( Point2D_F64 a , Point2D_F64 b , LineGeneral2D_F64 found ) { computeAdjustedEndPoints(a, b); return snapToEdge.refine(adjA, adjB, found); }
[ "protected", "boolean", "optimize", "(", "Point2D_F64", "a", ",", "Point2D_F64", "b", ",", "LineGeneral2D_F64", "found", ")", "{", "computeAdjustedEndPoints", "(", "a", ",", "b", ")", ";", "return", "snapToEdge", ".", "refine", "(", "adjA", ",", "adjB", ",",...
Fits a line defined by the two points. When fitting the line the weight of the edge is used to determine how influential the point is @param a Corner point in image coordinates. @param b Corner point in image coordinates. @param found (output) Line in image coordinates @return true if successful or false if it failed
[ "Fits", "a", "line", "defined", "by", "the", "two", "points", ".", "When", "fitting", "the", "line", "the", "weight", "of", "the", "edge", "is", "used", "to", "determine", "how", "influential", "the", "point", "is" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/polygon/RefinePolygonToGrayLine.java#L271-L276
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/feature/VisualizeRegions.java
VisualizeRegions.watersheds
public static BufferedImage watersheds(GrayS32 segments , BufferedImage output , int radius ) { if( output == null ) output = new BufferedImage(segments.width,segments.height,BufferedImage.TYPE_INT_RGB); if( radius <= 0 ) { for (int y = 0; y < segments.height; y++) { for (int x = 0; x < segments.width; x++) { int index = segments.unsafe_get(x, y); if (index == 0) output.setRGB(x, y, 0xFF0000); } } } else { for (int y = 0; y < segments.height; y++) { for (int x = 0; x < segments.width; x++) { int index = segments.unsafe_get(x, y); if (index == 0) { for (int i = -radius; i <= radius; i++) { int yy = y + i; for (int j = -radius; j <= radius; j++) { int xx = x + j; if (segments.isInBounds(xx, yy)) { output.setRGB(xx, yy, 0xFF0000); } } } } } } } return output; }
java
public static BufferedImage watersheds(GrayS32 segments , BufferedImage output , int radius ) { if( output == null ) output = new BufferedImage(segments.width,segments.height,BufferedImage.TYPE_INT_RGB); if( radius <= 0 ) { for (int y = 0; y < segments.height; y++) { for (int x = 0; x < segments.width; x++) { int index = segments.unsafe_get(x, y); if (index == 0) output.setRGB(x, y, 0xFF0000); } } } else { for (int y = 0; y < segments.height; y++) { for (int x = 0; x < segments.width; x++) { int index = segments.unsafe_get(x, y); if (index == 0) { for (int i = -radius; i <= radius; i++) { int yy = y + i; for (int j = -radius; j <= radius; j++) { int xx = x + j; if (segments.isInBounds(xx, yy)) { output.setRGB(xx, yy, 0xFF0000); } } } } } } } return output; }
[ "public", "static", "BufferedImage", "watersheds", "(", "GrayS32", "segments", ",", "BufferedImage", "output", ",", "int", "radius", ")", "{", "if", "(", "output", "==", "null", ")", "output", "=", "new", "BufferedImage", "(", "segments", ".", "width", ",", ...
Sets the pixels of each watershed as red in the output image. Watersheds have a value of 0 @param segments Conversion from pixel to region @param output Storage for output image. Can be null. @param radius Thickness of watershed. 0 is 1 pixel wide. 1 is 3 pixels wide. @return Output image.
[ "Sets", "the", "pixels", "of", "each", "watershed", "as", "red", "in", "the", "output", "image", ".", "Watersheds", "have", "a", "value", "of", "0" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/feature/VisualizeRegions.java#L43-L76
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/feature/VisualizeRegions.java
VisualizeRegions.regions
public static BufferedImage regions(GrayS32 pixelToRegion , int numRegions , BufferedImage output ) { return VisualizeBinaryData.renderLabeled(pixelToRegion,numRegions,output); }
java
public static BufferedImage regions(GrayS32 pixelToRegion , int numRegions , BufferedImage output ) { return VisualizeBinaryData.renderLabeled(pixelToRegion,numRegions,output); }
[ "public", "static", "BufferedImage", "regions", "(", "GrayS32", "pixelToRegion", ",", "int", "numRegions", ",", "BufferedImage", "output", ")", "{", "return", "VisualizeBinaryData", ".", "renderLabeled", "(", "pixelToRegion", ",", "numRegions", ",", "output", ")", ...
Draws each region with a random color @param pixelToRegion Conversion from pixel to region @param numRegions Total number of regions. @param output Storage for output image. Can be null. @return Output image.
[ "Draws", "each", "region", "with", "a", "random", "color" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/feature/VisualizeRegions.java#L85-L87
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/describe/brief/FactoryBriefDefinition.java
FactoryBriefDefinition.randomGaussian
private static void randomGaussian( Random rand , double sigma , int radius , Point2D_I32 pt ) { int x,y; while( true ) { x = (int)(rand.nextGaussian()*sigma); y = (int)(rand.nextGaussian()*sigma); if( Math.sqrt(x*x + y*y) < radius ) break; } pt.set(x,y); }
java
private static void randomGaussian( Random rand , double sigma , int radius , Point2D_I32 pt ) { int x,y; while( true ) { x = (int)(rand.nextGaussian()*sigma); y = (int)(rand.nextGaussian()*sigma); if( Math.sqrt(x*x + y*y) < radius ) break; } pt.set(x,y); }
[ "private", "static", "void", "randomGaussian", "(", "Random", "rand", ",", "double", "sigma", ",", "int", "radius", ",", "Point2D_I32", "pt", ")", "{", "int", "x", ",", "y", ";", "while", "(", "true", ")", "{", "x", "=", "(", "int", ")", "(", "rand...
Randomly selects a point which is inside a square region using a Gaussian distribution.
[ "Randomly", "selects", "a", "point", "which", "is", "inside", "a", "square", "region", "using", "a", "Gaussian", "distribution", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/describe/brief/FactoryBriefDefinition.java#L73-L85
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/factory/transform/pyramid/FactoryPyramid.java
FactoryPyramid.discreteGaussian
public static <T extends ImageBase<T>> PyramidDiscrete<T> discreteGaussian( int[] scaleFactors , double sigma , int radius , boolean saveOriginalReference, ImageType<T> imageType ) { Class<Kernel1D> kernelType = FactoryKernel.getKernelType(imageType.getDataType(),1); Kernel1D kernel = FactoryKernelGaussian.gaussian(kernelType,sigma,radius); return new PyramidDiscreteSampleBlur<>(kernel, sigma, imageType, saveOriginalReference, scaleFactors); }
java
public static <T extends ImageBase<T>> PyramidDiscrete<T> discreteGaussian( int[] scaleFactors , double sigma , int radius , boolean saveOriginalReference, ImageType<T> imageType ) { Class<Kernel1D> kernelType = FactoryKernel.getKernelType(imageType.getDataType(),1); Kernel1D kernel = FactoryKernelGaussian.gaussian(kernelType,sigma,radius); return new PyramidDiscreteSampleBlur<>(kernel, sigma, imageType, saveOriginalReference, scaleFactors); }
[ "public", "static", "<", "T", "extends", "ImageBase", "<", "T", ">", ">", "PyramidDiscrete", "<", "T", ">", "discreteGaussian", "(", "int", "[", "]", "scaleFactors", ",", "double", "sigma", ",", "int", "radius", ",", "boolean", "saveOriginalReference", ",", ...
Creates an updater for discrete pyramids where a Gaussian is convolved across the input prior to sub-sampling. @param imageType Type of input image. @param sigma Gaussian sigma. If < 0 then a sigma is selected using the radius. Try -1. @param radius Radius of the Gaussian kernel. If < 0 then the radius is selected using sigma. Try 2. @return PyramidDiscrete
[ "Creates", "an", "updater", "for", "discrete", "pyramids", "where", "a", "Gaussian", "is", "convolved", "across", "the", "input", "prior", "to", "sub", "-", "sampling", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/factory/transform/pyramid/FactoryPyramid.java#L52-L61
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/factory/transform/pyramid/FactoryPyramid.java
FactoryPyramid.floatGaussian
public static <T extends ImageGray<T>> PyramidFloat<T> floatGaussian( double scaleFactors[], double []sigmas , Class<T> imageType ) { InterpolatePixelS<T> interp = FactoryInterpolation.bilinearPixelS(imageType, BorderType.EXTENDED); return new PyramidFloatGaussianScale<>(interp, scaleFactors, sigmas, imageType); }
java
public static <T extends ImageGray<T>> PyramidFloat<T> floatGaussian( double scaleFactors[], double []sigmas , Class<T> imageType ) { InterpolatePixelS<T> interp = FactoryInterpolation.bilinearPixelS(imageType, BorderType.EXTENDED); return new PyramidFloatGaussianScale<>(interp, scaleFactors, sigmas, imageType); }
[ "public", "static", "<", "T", "extends", "ImageGray", "<", "T", ">", ">", "PyramidFloat", "<", "T", ">", "floatGaussian", "(", "double", "scaleFactors", "[", "]", ",", "double", "[", "]", "sigmas", ",", "Class", "<", "T", ">", "imageType", ")", "{", ...
Creates a float pyramid where each layer is blurred using a Gaussian with the specified sigma. Bilinear interpolation is used when sub-sampling. @param scaleFactors The scale factor of each layer relative to the previous layer. Layer 0 is relative to the input image. @param sigmas Gaussian blur magnitude for each layer. @param imageType Type of image in the pyramid. @return PyramidFloat
[ "Creates", "a", "float", "pyramid", "where", "each", "layer", "is", "blurred", "using", "a", "Gaussian", "with", "the", "specified", "sigma", ".", "Bilinear", "interpolation", "is", "used", "when", "sub", "-", "sampling", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/factory/transform/pyramid/FactoryPyramid.java#L73-L79
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/interpolate/array/LagrangeFormula.java
LagrangeFormula.process_F64
public static double process_F64(double sample, double x[], double y[], int i0, int i1) { double result = 0; for (int i = i0; i <= i1; i++) { double numerator = 1.0; for (int j = i0; j <= i1; j++) { if (i != j) numerator *= sample - x[j]; } double denominator = 1.0; double a = x[i]; for (int j = i0; j <= i1; j++) { if (i != j) denominator *= a - x[j]; } result += (numerator / denominator) * y[i]; } return result; }
java
public static double process_F64(double sample, double x[], double y[], int i0, int i1) { double result = 0; for (int i = i0; i <= i1; i++) { double numerator = 1.0; for (int j = i0; j <= i1; j++) { if (i != j) numerator *= sample - x[j]; } double denominator = 1.0; double a = x[i]; for (int j = i0; j <= i1; j++) { if (i != j) denominator *= a - x[j]; } result += (numerator / denominator) * y[i]; } return result; }
[ "public", "static", "double", "process_F64", "(", "double", "sample", ",", "double", "x", "[", "]", ",", "double", "y", "[", "]", ",", "int", "i0", ",", "int", "i1", ")", "{", "double", "result", "=", "0", ";", "for", "(", "int", "i", "=", "i0", ...
UsingLlangrange's formula it interpulates the value of a function at the specified sample point given discrete samples. Which samples are used and the order of the approximation are given by i0 and i1. @param sample Where the estimate is done. @param x Where the function was sampled. @param y The function's value at the sample points @param i0 The first point considered. @param i1 The last point considered. @return The estimated y value at the sample point.
[ "UsingLlangrange", "s", "formula", "it", "interpulates", "the", "value", "of", "a", "function", "at", "the", "specified", "sample", "point", "given", "discrete", "samples", ".", "Which", "samples", "are", "used", "and", "the", "order", "of", "the", "approximat...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/interpolate/array/LagrangeFormula.java#L43-L67
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/d3/Polygon3DSequenceViewer.java
Polygon3DSequenceViewer.add
public void add( Color color , Point3D_F64... polygon ) { final Poly p = new Poly(polygon.length,color); for( int i = 0; i < polygon.length; i++ ) p.pts[i] = polygon[i].copy(); synchronized (polygons) { polygons.add( p ); } }
java
public void add( Color color , Point3D_F64... polygon ) { final Poly p = new Poly(polygon.length,color); for( int i = 0; i < polygon.length; i++ ) p.pts[i] = polygon[i].copy(); synchronized (polygons) { polygons.add( p ); } }
[ "public", "void", "add", "(", "Color", "color", ",", "Point3D_F64", "...", "polygon", ")", "{", "final", "Poly", "p", "=", "new", "Poly", "(", "polygon", ".", "length", ",", "color", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "pol...
Adds a polygon to the viewer. GUI Thread safe. @param polygon shape being added
[ "Adds", "a", "polygon", "to", "the", "viewer", ".", "GUI", "Thread", "safe", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/d3/Polygon3DSequenceViewer.java#L108-L118
train
lessthanoptimal/BoofCV
main/boofcv-io/src/main/java/boofcv/io/image/ConvertBufferedImage.java
ConvertBufferedImage.checkDeclare
public static BufferedImage checkDeclare( int width , int height , BufferedImage image , int type ) { if( image == null ) return new BufferedImage(width,height,type); if( image.getType() != type ) return new BufferedImage(width,height,type); if( image.getWidth() != width || image.getHeight() != height ) return new BufferedImage(width,height,type); return image; }
java
public static BufferedImage checkDeclare( int width , int height , BufferedImage image , int type ) { if( image == null ) return new BufferedImage(width,height,type); if( image.getType() != type ) return new BufferedImage(width,height,type); if( image.getWidth() != width || image.getHeight() != height ) return new BufferedImage(width,height,type); return image; }
[ "public", "static", "BufferedImage", "checkDeclare", "(", "int", "width", ",", "int", "height", ",", "BufferedImage", "image", ",", "int", "type", ")", "{", "if", "(", "image", "==", "null", ")", "return", "new", "BufferedImage", "(", "width", ",", "height...
If the provided image does not have the same shape and same type a new one is declared and returned.
[ "If", "the", "provided", "image", "does", "not", "have", "the", "same", "shape", "and", "same", "type", "a", "new", "one", "is", "declared", "and", "returned", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-io/src/main/java/boofcv/io/image/ConvertBufferedImage.java#L43-L51
train
lessthanoptimal/BoofCV
main/boofcv-io/src/main/java/boofcv/io/image/ConvertBufferedImage.java
ConvertBufferedImage.checkCopy
public static BufferedImage checkCopy( BufferedImage original , BufferedImage output ) { ColorModel cm = original.getColorModel(); boolean isAlphaPremultiplied = cm.isAlphaPremultiplied(); if( output == null || original.getWidth() != output.getWidth() || original.getHeight() != output.getHeight() || original.getType() != output.getType() ) { WritableRaster raster = original.copyData(original.getRaster().createCompatibleWritableRaster()); return new BufferedImage(cm, raster, isAlphaPremultiplied, null); } original.copyData(output.getRaster()); return output; }
java
public static BufferedImage checkCopy( BufferedImage original , BufferedImage output ) { ColorModel cm = original.getColorModel(); boolean isAlphaPremultiplied = cm.isAlphaPremultiplied(); if( output == null || original.getWidth() != output.getWidth() || original.getHeight() != output.getHeight() || original.getType() != output.getType() ) { WritableRaster raster = original.copyData(original.getRaster().createCompatibleWritableRaster()); return new BufferedImage(cm, raster, isAlphaPremultiplied, null); } original.copyData(output.getRaster()); return output; }
[ "public", "static", "BufferedImage", "checkCopy", "(", "BufferedImage", "original", ",", "BufferedImage", "output", ")", "{", "ColorModel", "cm", "=", "original", ".", "getColorModel", "(", ")", ";", "boolean", "isAlphaPremultiplied", "=", "cm", ".", "isAlphaPremu...
Copies the original image into the output image. If it can't do a copy a new image is created and returned @param original Original image @param output (Optional) Storage for copy. @return The copied image. May be a new instance
[ "Copies", "the", "original", "image", "into", "the", "output", "image", ".", "If", "it", "can", "t", "do", "a", "copy", "a", "new", "image", "is", "created", "and", "returned" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-io/src/main/java/boofcv/io/image/ConvertBufferedImage.java#L79-L91
train
lessthanoptimal/BoofCV
main/boofcv-io/src/main/java/boofcv/io/image/ConvertBufferedImage.java
ConvertBufferedImage.stripAlphaChannel
public static BufferedImage stripAlphaChannel( BufferedImage image ) { int numBands = image.getRaster().getNumBands(); if( numBands == 4 ) { BufferedImage output = new BufferedImage(image.getWidth(),image.getHeight(),BufferedImage.TYPE_INT_RGB); output.createGraphics().drawImage(image,0,0,null); return output; } else { return image; } }
java
public static BufferedImage stripAlphaChannel( BufferedImage image ) { int numBands = image.getRaster().getNumBands(); if( numBands == 4 ) { BufferedImage output = new BufferedImage(image.getWidth(),image.getHeight(),BufferedImage.TYPE_INT_RGB); output.createGraphics().drawImage(image,0,0,null); return output; } else { return image; } }
[ "public", "static", "BufferedImage", "stripAlphaChannel", "(", "BufferedImage", "image", ")", "{", "int", "numBands", "=", "image", ".", "getRaster", "(", ")", ".", "getNumBands", "(", ")", ";", "if", "(", "numBands", "==", "4", ")", "{", "BufferedImage", ...
Returns an image which doesn't have an alpha channel. If the input image doesn't have an alpha channel to start then its returned as is. Otherwise a new image is created and the RGB channels are copied and the new image returned. @param image Input image @return Image without an alpha channel
[ "Returns", "an", "image", "which", "doesn", "t", "have", "an", "alpha", "channel", ".", "If", "the", "input", "image", "doesn", "t", "have", "an", "alpha", "channel", "to", "start", "then", "its", "returned", "as", "is", ".", "Otherwise", "a", "new", "...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-io/src/main/java/boofcv/io/image/ConvertBufferedImage.java#L101-L111
train
lessthanoptimal/BoofCV
main/boofcv-io/src/main/java/boofcv/io/image/ConvertBufferedImage.java
ConvertBufferedImage.extractInterleavedU8
public static InterleavedU8 extractInterleavedU8(BufferedImage img) { DataBuffer buffer = img.getRaster().getDataBuffer(); if (buffer.getDataType() == DataBuffer.TYPE_BYTE && isKnownByteFormat(img) ) { WritableRaster raster = img.getRaster(); InterleavedU8 ret = new InterleavedU8(); ret.width = img.getWidth(); ret.height = img.getHeight(); ret.startIndex = ConvertRaster.getOffset(raster); ret.imageType.numBands = raster.getNumBands(); ret.numBands = raster.getNumBands(); ret.stride = ConvertRaster.stride(raster); ret.data = ((DataBufferByte)buffer).getData(); ret.subImage = ret.startIndex != 0; return ret; } throw new IllegalArgumentException("Buffered image does not have an interleaved byte raster"); }
java
public static InterleavedU8 extractInterleavedU8(BufferedImage img) { DataBuffer buffer = img.getRaster().getDataBuffer(); if (buffer.getDataType() == DataBuffer.TYPE_BYTE && isKnownByteFormat(img) ) { WritableRaster raster = img.getRaster(); InterleavedU8 ret = new InterleavedU8(); ret.width = img.getWidth(); ret.height = img.getHeight(); ret.startIndex = ConvertRaster.getOffset(raster); ret.imageType.numBands = raster.getNumBands(); ret.numBands = raster.getNumBands(); ret.stride = ConvertRaster.stride(raster); ret.data = ((DataBufferByte)buffer).getData(); ret.subImage = ret.startIndex != 0; return ret; } throw new IllegalArgumentException("Buffered image does not have an interleaved byte raster"); }
[ "public", "static", "InterleavedU8", "extractInterleavedU8", "(", "BufferedImage", "img", ")", "{", "DataBuffer", "buffer", "=", "img", ".", "getRaster", "(", ")", ".", "getDataBuffer", "(", ")", ";", "if", "(", "buffer", ".", "getDataType", "(", ")", "==", ...
For BufferedImage stored as a byte array internally it extracts an interleaved image. The input image and the returned image will both share the same internal data array. Using this function allows unnecessary memory copying to be avoided. @param img Image whose internal data is extracted and wrapped. @return An image whose internal data is the same as the input image.
[ "For", "BufferedImage", "stored", "as", "a", "byte", "array", "internally", "it", "extracts", "an", "interleaved", "image", ".", "The", "input", "image", "and", "the", "returned", "image", "will", "both", "share", "the", "same", "internal", "data", "array", ...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-io/src/main/java/boofcv/io/image/ConvertBufferedImage.java#L122-L142
train
lessthanoptimal/BoofCV
main/boofcv-io/src/main/java/boofcv/io/image/ConvertBufferedImage.java
ConvertBufferedImage.extractGrayU8
public static GrayU8 extractGrayU8(BufferedImage img) { WritableRaster raster = img.getRaster(); DataBuffer buffer = raster.getDataBuffer(); if (buffer.getDataType() == DataBuffer.TYPE_BYTE && isKnownByteFormat(img) ) { if (raster.getNumBands() != 1) throw new IllegalArgumentException("Input image has more than one channel"); GrayU8 ret = new GrayU8(); ret.width = img.getWidth(); ret.height = img.getHeight(); ret.startIndex = ConvertRaster.getOffset(img.getRaster()); ret.stride = ConvertRaster.stride(img.getRaster()); ret.data = ((DataBufferByte)buffer).getData(); return ret; } throw new IllegalArgumentException("Buffered image does not have a gray scale byte raster"); }
java
public static GrayU8 extractGrayU8(BufferedImage img) { WritableRaster raster = img.getRaster(); DataBuffer buffer = raster.getDataBuffer(); if (buffer.getDataType() == DataBuffer.TYPE_BYTE && isKnownByteFormat(img) ) { if (raster.getNumBands() != 1) throw new IllegalArgumentException("Input image has more than one channel"); GrayU8 ret = new GrayU8(); ret.width = img.getWidth(); ret.height = img.getHeight(); ret.startIndex = ConvertRaster.getOffset(img.getRaster()); ret.stride = ConvertRaster.stride(img.getRaster()); ret.data = ((DataBufferByte)buffer).getData(); return ret; } throw new IllegalArgumentException("Buffered image does not have a gray scale byte raster"); }
[ "public", "static", "GrayU8", "extractGrayU8", "(", "BufferedImage", "img", ")", "{", "WritableRaster", "raster", "=", "img", ".", "getRaster", "(", ")", ";", "DataBuffer", "buffer", "=", "raster", ".", "getDataBuffer", "(", ")", ";", "if", "(", "buffer", ...
For BufferedImage stored as a byte array internally it extracts an image. The input image and the returned image will both share the same internal data array. Using this function allows unnecessary memory copying to be avoided. @param img Image whose internal data is extracted and wrapped. @return An image whose internal data is the same as the input image.
[ "For", "BufferedImage", "stored", "as", "a", "byte", "array", "internally", "it", "extracts", "an", "image", ".", "The", "input", "image", "and", "the", "returned", "image", "will", "both", "share", "the", "same", "internal", "data", "array", ".", "Using", ...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-io/src/main/java/boofcv/io/image/ConvertBufferedImage.java#L153-L171
train
lessthanoptimal/BoofCV
main/boofcv-io/src/main/java/boofcv/io/image/ConvertBufferedImage.java
ConvertBufferedImage.convertFromSingle
public static <T extends ImageGray<T>> T convertFromSingle(BufferedImage src, T dst, Class<T> type) { if (type == GrayU8.class) { return (T) convertFrom(src, (GrayU8) dst); } else if( GrayI16.class.isAssignableFrom(type) ) { return (T) convertFrom(src, (GrayI16) dst,(Class)type); } else if (type == GrayF32.class) { return (T) convertFrom(src, (GrayF32) dst); } else { throw new IllegalArgumentException("Unknown type " + type); } }
java
public static <T extends ImageGray<T>> T convertFromSingle(BufferedImage src, T dst, Class<T> type) { if (type == GrayU8.class) { return (T) convertFrom(src, (GrayU8) dst); } else if( GrayI16.class.isAssignableFrom(type) ) { return (T) convertFrom(src, (GrayI16) dst,(Class)type); } else if (type == GrayF32.class) { return (T) convertFrom(src, (GrayF32) dst); } else { throw new IllegalArgumentException("Unknown type " + type); } }
[ "public", "static", "<", "T", "extends", "ImageGray", "<", "T", ">", ">", "T", "convertFromSingle", "(", "BufferedImage", "src", ",", "T", "dst", ",", "Class", "<", "T", ">", "type", ")", "{", "if", "(", "type", "==", "GrayU8", ".", "class", ")", "...
Converts a buffered image into an image of the specified type. In a 'dst' image is provided it will be used for output, otherwise a new image will be created.
[ "Converts", "a", "buffered", "image", "into", "an", "image", "of", "the", "specified", "type", ".", "In", "a", "dst", "image", "is", "provided", "it", "will", "be", "used", "for", "output", "otherwise", "a", "new", "image", "will", "be", "created", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-io/src/main/java/boofcv/io/image/ConvertBufferedImage.java#L343-L353
train
lessthanoptimal/BoofCV
main/boofcv-io/src/main/java/boofcv/io/image/ConvertBufferedImage.java
ConvertBufferedImage.convertTo
public static BufferedImage convertTo(JComponent comp, BufferedImage storage) { if (storage == null) storage = new BufferedImage(comp.getWidth(), comp.getHeight(), BufferedImage.TYPE_INT_RGB); Graphics2D g2 = storage.createGraphics(); comp.paintComponents(g2); return storage; }
java
public static BufferedImage convertTo(JComponent comp, BufferedImage storage) { if (storage == null) storage = new BufferedImage(comp.getWidth(), comp.getHeight(), BufferedImage.TYPE_INT_RGB); Graphics2D g2 = storage.createGraphics(); comp.paintComponents(g2); return storage; }
[ "public", "static", "BufferedImage", "convertTo", "(", "JComponent", "comp", ",", "BufferedImage", "storage", ")", "{", "if", "(", "storage", "==", "null", ")", "storage", "=", "new", "BufferedImage", "(", "comp", ".", "getWidth", "(", ")", ",", "comp", "....
Draws the component into a BufferedImage. @param comp The component being drawn into an image. @param storage if not null the component is drawn into it, if null a new BufferedImage is created. @return image of the component
[ "Draws", "the", "component", "into", "a", "BufferedImage", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-io/src/main/java/boofcv/io/image/ConvertBufferedImage.java#L915-L924
train
lessthanoptimal/BoofCV
main/boofcv-io/src/main/java/boofcv/io/image/ConvertBufferedImage.java
ConvertBufferedImage.orderBandsIntoBuffered
public static Planar orderBandsIntoBuffered(Planar src, BufferedImage dst) { // see if no change is required if( dst.getType() == BufferedImage.TYPE_INT_RGB ) return src; Planar tmp = new Planar(src.type, src.getNumBands()); tmp.width = src.width; tmp.height = src.height; tmp.stride = src.stride; tmp.startIndex = src.startIndex; for( int i = 0; i < src.getNumBands(); i++ ) { tmp.bands[i] = src.bands[i]; } ConvertRaster.orderBandsBufferedFromRgb(tmp, dst); return tmp; }
java
public static Planar orderBandsIntoBuffered(Planar src, BufferedImage dst) { // see if no change is required if( dst.getType() == BufferedImage.TYPE_INT_RGB ) return src; Planar tmp = new Planar(src.type, src.getNumBands()); tmp.width = src.width; tmp.height = src.height; tmp.stride = src.stride; tmp.startIndex = src.startIndex; for( int i = 0; i < src.getNumBands(); i++ ) { tmp.bands[i] = src.bands[i]; } ConvertRaster.orderBandsBufferedFromRgb(tmp, dst); return tmp; }
[ "public", "static", "Planar", "orderBandsIntoBuffered", "(", "Planar", "src", ",", "BufferedImage", "dst", ")", "{", "// see if no change is required", "if", "(", "dst", ".", "getType", "(", ")", "==", "BufferedImage", ".", "TYPE_INT_RGB", ")", "return", "src", ...
Returns a new image with the color bands in the appropriate ordering. The returned image will reference the original image's image arrays.
[ "Returns", "a", "new", "image", "with", "the", "color", "bands", "in", "the", "appropriate", "ordering", ".", "The", "returned", "image", "will", "reference", "the", "original", "image", "s", "image", "arrays", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-io/src/main/java/boofcv/io/image/ConvertBufferedImage.java#L930-L945
train
lessthanoptimal/BoofCV
demonstrations/src/main/java/boofcv/demonstrations/enhance/DenoiseVisualizeApp.java
DenoiseVisualizeApp.computeError
public static double computeError(GrayF32 imgA, GrayF32 imgB ) { final int h = imgA.getHeight(); final int w = imgA.getWidth(); double total = 0; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { double difference = Math.abs(imgA.get(x,y)-imgB.get(x,y)); total += difference; } } return total / (w*h); }
java
public static double computeError(GrayF32 imgA, GrayF32 imgB ) { final int h = imgA.getHeight(); final int w = imgA.getWidth(); double total = 0; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { double difference = Math.abs(imgA.get(x,y)-imgB.get(x,y)); total += difference; } } return total / (w*h); }
[ "public", "static", "double", "computeError", "(", "GrayF32", "imgA", ",", "GrayF32", "imgB", ")", "{", "final", "int", "h", "=", "imgA", ".", "getHeight", "(", ")", ";", "final", "int", "w", "=", "imgA", ".", "getWidth", "(", ")", ";", "double", "to...
todo push to what ops? Also what is this error called again?
[ "todo", "push", "to", "what", "ops?", "Also", "what", "is", "this", "error", "called", "again?" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/demonstrations/src/main/java/boofcv/demonstrations/enhance/DenoiseVisualizeApp.java#L285-L299
train
lessthanoptimal/BoofCV
demonstrations/src/main/java/boofcv/demonstrations/enhance/DenoiseVisualizeApp.java
DenoiseVisualizeApp.computeWeightedError
public static double computeWeightedError(GrayF32 imgA, GrayF32 imgB , GrayF32 imgWeight ) { final int h = imgA.getHeight(); final int w = imgA.getWidth(); double total = 0; double totalWeight = 0; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { float weight = imgWeight.get(x,y); double difference = Math.abs(imgA.get(x,y)-imgB.get(x,y)); total += difference*weight; totalWeight += weight; } } return total / totalWeight; }
java
public static double computeWeightedError(GrayF32 imgA, GrayF32 imgB , GrayF32 imgWeight ) { final int h = imgA.getHeight(); final int w = imgA.getWidth(); double total = 0; double totalWeight = 0; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { float weight = imgWeight.get(x,y); double difference = Math.abs(imgA.get(x,y)-imgB.get(x,y)); total += difference*weight; totalWeight += weight; } } return total / totalWeight; }
[ "public", "static", "double", "computeWeightedError", "(", "GrayF32", "imgA", ",", "GrayF32", "imgB", ",", "GrayF32", "imgWeight", ")", "{", "final", "int", "h", "=", "imgA", ".", "getHeight", "(", ")", ";", "final", "int", "w", "=", "imgA", ".", "getWid...
todo push to what ops?
[ "todo", "push", "to", "what", "ops?" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/demonstrations/src/main/java/boofcv/demonstrations/enhance/DenoiseVisualizeApp.java#L302-L320
train
lessthanoptimal/BoofCV
examples/src/main/java/boofcv/examples/geometry/ExampleVideoMosaic.java
ExampleVideoMosaic.nearBorder
private static boolean nearBorder( Point2D_F64 p , StitchingFromMotion2D<?,?> stitch ) { int r = 10; if( p.x < r || p.y < r ) return true; if( p.x >= stitch.getStitchedImage().width-r ) return true; if( p.y >= stitch.getStitchedImage().height-r ) return true; return false; }
java
private static boolean nearBorder( Point2D_F64 p , StitchingFromMotion2D<?,?> stitch ) { int r = 10; if( p.x < r || p.y < r ) return true; if( p.x >= stitch.getStitchedImage().width-r ) return true; if( p.y >= stitch.getStitchedImage().height-r ) return true; return false; }
[ "private", "static", "boolean", "nearBorder", "(", "Point2D_F64", "p", ",", "StitchingFromMotion2D", "<", "?", ",", "?", ">", "stitch", ")", "{", "int", "r", "=", "10", ";", "if", "(", "p", ".", "x", "<", "r", "||", "p", ".", "y", "<", "r", ")", ...
Checks to see if the point is near the image border
[ "Checks", "to", "see", "if", "the", "point", "is", "near", "the", "image", "border" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/geometry/ExampleVideoMosaic.java#L162-L172
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/abst/fiducial/FourPointSyntheticStability.java
FourPointSyntheticStability.setShape
public void setShape(double width , double height ) { points2D3D.get(0).location.set(-width/2,-height/2,0); points2D3D.get(1).location.set(-width/2, height/2,0); points2D3D.get(2).location.set( width/2, height/2,0); points2D3D.get(3).location.set( width/2,-height/2,0); }
java
public void setShape(double width , double height ) { points2D3D.get(0).location.set(-width/2,-height/2,0); points2D3D.get(1).location.set(-width/2, height/2,0); points2D3D.get(2).location.set( width/2, height/2,0); points2D3D.get(3).location.set( width/2,-height/2,0); }
[ "public", "void", "setShape", "(", "double", "width", ",", "double", "height", ")", "{", "points2D3D", ".", "get", "(", "0", ")", ".", "location", ".", "set", "(", "-", "width", "/", "2", ",", "-", "height", "/", "2", ",", "0", ")", ";", "points2...
Specifes how big the fiducial is along two axises @param width Length along x-axis @param height Length along y-axis
[ "Specifes", "how", "big", "the", "fiducial", "is", "along", "two", "axises" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/abst/fiducial/FourPointSyntheticStability.java#L95-L100
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/abst/fiducial/FourPointSyntheticStability.java
FourPointSyntheticStability.computeStability
public void computeStability(Se3_F64 targetToCamera , double disturbance, FiducialStability results) { targetToCamera.invert(referenceCameraToTarget); maxOrientation = 0; maxLocation = 0; Point3D_F64 cameraPt = new Point3D_F64(); for (int i = 0; i < points2D3D.size(); i++) { Point2D3D p23 = points2D3D.get(i); targetToCamera.transform(p23.location,cameraPt); p23.observation.x = cameraPt.x/cameraPt.z; p23.observation.y = cameraPt.y/cameraPt.z; refNorm.get(i).set(p23.observation); normToPixel.compute(p23.observation.x,p23.observation.y,refPixels.get(i)); } for (int i = 0; i < points2D3D.size(); i++) { // see what happens if you tweak this observation a little bit perturb( disturbance, refPixels.get(i), points2D3D.get(i)); // set it back to the nominal value points2D3D.get(i).observation.set(refNorm.get(i)); } results.location = maxLocation; results.orientation = maxOrientation; }
java
public void computeStability(Se3_F64 targetToCamera , double disturbance, FiducialStability results) { targetToCamera.invert(referenceCameraToTarget); maxOrientation = 0; maxLocation = 0; Point3D_F64 cameraPt = new Point3D_F64(); for (int i = 0; i < points2D3D.size(); i++) { Point2D3D p23 = points2D3D.get(i); targetToCamera.transform(p23.location,cameraPt); p23.observation.x = cameraPt.x/cameraPt.z; p23.observation.y = cameraPt.y/cameraPt.z; refNorm.get(i).set(p23.observation); normToPixel.compute(p23.observation.x,p23.observation.y,refPixels.get(i)); } for (int i = 0; i < points2D3D.size(); i++) { // see what happens if you tweak this observation a little bit perturb( disturbance, refPixels.get(i), points2D3D.get(i)); // set it back to the nominal value points2D3D.get(i).observation.set(refNorm.get(i)); } results.location = maxLocation; results.orientation = maxOrientation; }
[ "public", "void", "computeStability", "(", "Se3_F64", "targetToCamera", ",", "double", "disturbance", ",", "FiducialStability", "results", ")", "{", "targetToCamera", ".", "invert", "(", "referenceCameraToTarget", ")", ";", "maxOrientation", "=", "0", ";", "maxLocat...
Estimate how sensitive this observation is to pixel noise @param targetToCamera Observed target to camera pose estimate @param disturbance How much the observation should be noised up, in pixels @param results description how how sensitive the stability estimate is @return true if stability could be computed
[ "Estimate", "how", "sensitive", "this", "observation", "is", "to", "pixel", "noise" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/abst/fiducial/FourPointSyntheticStability.java#L109-L140
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/abst/fiducial/FourPointSyntheticStability.java
FourPointSyntheticStability.perturb
private void perturb(double disturbance , Point2D_F64 pixel , Point2D3D p23 ) { double x; double y = pixel.y; x = pixel.x + disturbance; computeDisturbance( x,y, p23); x = pixel.x - disturbance; computeDisturbance( x,y, p23); x = pixel.x; y = pixel.y + disturbance; computeDisturbance( x,y, p23); y = pixel.y - disturbance; computeDisturbance( x,y, p23); }
java
private void perturb(double disturbance , Point2D_F64 pixel , Point2D3D p23 ) { double x; double y = pixel.y; x = pixel.x + disturbance; computeDisturbance( x,y, p23); x = pixel.x - disturbance; computeDisturbance( x,y, p23); x = pixel.x; y = pixel.y + disturbance; computeDisturbance( x,y, p23); y = pixel.y - disturbance; computeDisturbance( x,y, p23); }
[ "private", "void", "perturb", "(", "double", "disturbance", ",", "Point2D_F64", "pixel", ",", "Point2D3D", "p23", ")", "{", "double", "x", ";", "double", "y", "=", "pixel", ".", "y", ";", "x", "=", "pixel", ".", "x", "+", "disturbance", ";", "computeDi...
Perturb the observation in 4 different ways @param disturbance distance of pixel the observed point will be offset by @param pixel observed pixel @param p23 observation plugged into PnP
[ "Perturb", "the", "observation", "in", "4", "different", "ways" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/abst/fiducial/FourPointSyntheticStability.java#L149-L162
train
lessthanoptimal/BoofCV
examples/src/main/java/boofcv/examples/features/ExampleLineDetection.java
ExampleLineDetection.detectLines
public static<T extends ImageGray<T>, D extends ImageGray<D>> void detectLines( BufferedImage image , Class<T> imageType , Class<D> derivType ) { // convert the line into a single band image T input = ConvertBufferedImage.convertFromSingle(image, null, imageType ); // Comment/uncomment to try a different type of line detector DetectLineHoughPolar<T,D> detector = FactoryDetectLineAlgs.houghPolar( new ConfigHoughPolar(3, 30, 2, Math.PI / 180,edgeThreshold, maxLines), imageType, derivType); // DetectLineHoughFoot<T,D> detector = FactoryDetectLineAlgs.houghFoot( // new ConfigHoughFoot(3, 8, 5, edgeThreshold,maxLines), imageType, derivType); // DetectLineHoughFootSubimage<T,D> detector = FactoryDetectLineAlgs.houghFootSub( // new ConfigHoughFootSubimage(3, 8, 5, edgeThreshold,maxLines, 2, 2), imageType, derivType); List<LineParametric2D_F32> found = detector.detect(input); // display the results ImageLinePanel gui = new ImageLinePanel(); gui.setImage(image); gui.setLines(found); gui.setPreferredSize(new Dimension(image.getWidth(),image.getHeight())); listPanel.addItem(gui, "Found Lines"); }
java
public static<T extends ImageGray<T>, D extends ImageGray<D>> void detectLines( BufferedImage image , Class<T> imageType , Class<D> derivType ) { // convert the line into a single band image T input = ConvertBufferedImage.convertFromSingle(image, null, imageType ); // Comment/uncomment to try a different type of line detector DetectLineHoughPolar<T,D> detector = FactoryDetectLineAlgs.houghPolar( new ConfigHoughPolar(3, 30, 2, Math.PI / 180,edgeThreshold, maxLines), imageType, derivType); // DetectLineHoughFoot<T,D> detector = FactoryDetectLineAlgs.houghFoot( // new ConfigHoughFoot(3, 8, 5, edgeThreshold,maxLines), imageType, derivType); // DetectLineHoughFootSubimage<T,D> detector = FactoryDetectLineAlgs.houghFootSub( // new ConfigHoughFootSubimage(3, 8, 5, edgeThreshold,maxLines, 2, 2), imageType, derivType); List<LineParametric2D_F32> found = detector.detect(input); // display the results ImageLinePanel gui = new ImageLinePanel(); gui.setImage(image); gui.setLines(found); gui.setPreferredSize(new Dimension(image.getWidth(),image.getHeight())); listPanel.addItem(gui, "Found Lines"); }
[ "public", "static", "<", "T", "extends", "ImageGray", "<", "T", ">", ",", "D", "extends", "ImageGray", "<", "D", ">", ">", "void", "detectLines", "(", "BufferedImage", "image", ",", "Class", "<", "T", ">", "imageType", ",", "Class", "<", "D", ">", "d...
Detects lines inside the image using different types of Hough detectors @param image Input image. @param imageType Type of image processed by line detector. @param derivType Type of image derivative.
[ "Detects", "lines", "inside", "the", "image", "using", "different", "types", "of", "Hough", "detectors" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/features/ExampleLineDetection.java#L63-L88
train
lessthanoptimal/BoofCV
examples/src/main/java/boofcv/examples/features/ExampleLineDetection.java
ExampleLineDetection.detectLineSegments
public static<T extends ImageGray<T>, D extends ImageGray<D>> void detectLineSegments( BufferedImage image , Class<T> imageType , Class<D> derivType ) { // convert the line into a single band image T input = ConvertBufferedImage.convertFromSingle(image, null, imageType ); // Comment/uncomment to try a different type of line detector DetectLineSegmentsGridRansac<T,D> detector = FactoryDetectLineAlgs.lineRansac(40, 30, 2.36, true, imageType, derivType); List<LineSegment2D_F32> found = detector.detect(input); // display the results ImageLinePanel gui = new ImageLinePanel(); gui.setImage(image); gui.setLineSegments(found); gui.setPreferredSize(new Dimension(image.getWidth(),image.getHeight())); listPanel.addItem(gui, "Found Line Segments"); }
java
public static<T extends ImageGray<T>, D extends ImageGray<D>> void detectLineSegments( BufferedImage image , Class<T> imageType , Class<D> derivType ) { // convert the line into a single band image T input = ConvertBufferedImage.convertFromSingle(image, null, imageType ); // Comment/uncomment to try a different type of line detector DetectLineSegmentsGridRansac<T,D> detector = FactoryDetectLineAlgs.lineRansac(40, 30, 2.36, true, imageType, derivType); List<LineSegment2D_F32> found = detector.detect(input); // display the results ImageLinePanel gui = new ImageLinePanel(); gui.setImage(image); gui.setLineSegments(found); gui.setPreferredSize(new Dimension(image.getWidth(),image.getHeight())); listPanel.addItem(gui, "Found Line Segments"); }
[ "public", "static", "<", "T", "extends", "ImageGray", "<", "T", ">", ",", "D", "extends", "ImageGray", "<", "D", ">", ">", "void", "detectLineSegments", "(", "BufferedImage", "image", ",", "Class", "<", "T", ">", "imageType", ",", "Class", "<", "D", ">...
Detects segments inside the image @param image Input image. @param imageType Type of image processed by line detector. @param derivType Type of image derivative.
[ "Detects", "segments", "inside", "the", "image" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/features/ExampleLineDetection.java#L97-L117
train
lessthanoptimal/BoofCV
examples/src/main/java/boofcv/examples/recognition/ExampleColorHistogramLookup.java
ExampleColorHistogramLookup.coupledHueSat
public static List<double[]> coupledHueSat( List<String> images ) { List<double[]> points = new ArrayList<>(); Planar<GrayF32> rgb = new Planar<>(GrayF32.class,1,1,3); Planar<GrayF32> hsv = new Planar<>(GrayF32.class,1,1,3); for( String path : images ) { BufferedImage buffered = UtilImageIO.loadImage(path); if( buffered == null ) throw new RuntimeException("Can't load image!"); rgb.reshape(buffered.getWidth(), buffered.getHeight()); hsv.reshape(buffered.getWidth(), buffered.getHeight()); ConvertBufferedImage.convertFrom(buffered, rgb, true); ColorHsv.rgbToHsv(rgb, hsv); Planar<GrayF32> hs = hsv.partialSpectrum(0,1); // The number of bins is an important parameter. Try adjusting it Histogram_F64 histogram = new Histogram_F64(12,12); histogram.setRange(0, 0, 2.0*Math.PI); // range of hue is from 0 to 2PI histogram.setRange(1, 0, 1.0); // range of saturation is from 0 to 1 // Compute the histogram GHistogramFeatureOps.histogram(hs,histogram); UtilFeature.normalizeL2(histogram); // normalize so that image size doesn't matter points.add(histogram.value); } return points; }
java
public static List<double[]> coupledHueSat( List<String> images ) { List<double[]> points = new ArrayList<>(); Planar<GrayF32> rgb = new Planar<>(GrayF32.class,1,1,3); Planar<GrayF32> hsv = new Planar<>(GrayF32.class,1,1,3); for( String path : images ) { BufferedImage buffered = UtilImageIO.loadImage(path); if( buffered == null ) throw new RuntimeException("Can't load image!"); rgb.reshape(buffered.getWidth(), buffered.getHeight()); hsv.reshape(buffered.getWidth(), buffered.getHeight()); ConvertBufferedImage.convertFrom(buffered, rgb, true); ColorHsv.rgbToHsv(rgb, hsv); Planar<GrayF32> hs = hsv.partialSpectrum(0,1); // The number of bins is an important parameter. Try adjusting it Histogram_F64 histogram = new Histogram_F64(12,12); histogram.setRange(0, 0, 2.0*Math.PI); // range of hue is from 0 to 2PI histogram.setRange(1, 0, 1.0); // range of saturation is from 0 to 1 // Compute the histogram GHistogramFeatureOps.histogram(hs,histogram); UtilFeature.normalizeL2(histogram); // normalize so that image size doesn't matter points.add(histogram.value); } return points; }
[ "public", "static", "List", "<", "double", "[", "]", ">", "coupledHueSat", "(", "List", "<", "String", ">", "images", ")", "{", "List", "<", "double", "[", "]", ">", "points", "=", "new", "ArrayList", "<>", "(", ")", ";", "Planar", "<", "GrayF32", ...
HSV stores color information in Hue and Saturation while intensity is in Value. This computes a 2D histogram from hue and saturation only, which makes it lighting independent.
[ "HSV", "stores", "color", "information", "in", "Hue", "and", "Saturation", "while", "intensity", "is", "in", "Value", ".", "This", "computes", "a", "2D", "histogram", "from", "hue", "and", "saturation", "only", "which", "makes", "it", "lighting", "independent"...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/recognition/ExampleColorHistogramLookup.java#L70-L102
train
lessthanoptimal/BoofCV
examples/src/main/java/boofcv/examples/recognition/ExampleColorHistogramLookup.java
ExampleColorHistogramLookup.independentHueSat
public static List<double[]> independentHueSat( List<File> images ) { List<double[]> points = new ArrayList<>(); // The number of bins is an important parameter. Try adjusting it TupleDesc_F64 histogramHue = new TupleDesc_F64(30); TupleDesc_F64 histogramValue = new TupleDesc_F64(30); List<TupleDesc_F64> histogramList = new ArrayList<>(); histogramList.add(histogramHue); histogramList.add(histogramValue); Planar<GrayF32> rgb = new Planar<>(GrayF32.class,1,1,3); Planar<GrayF32> hsv = new Planar<>(GrayF32.class,1,1,3); for( File f : images ) { BufferedImage buffered = UtilImageIO.loadImage(f.getPath()); if( buffered == null ) throw new RuntimeException("Can't load image!"); rgb.reshape(buffered.getWidth(), buffered.getHeight()); hsv.reshape(buffered.getWidth(), buffered.getHeight()); ConvertBufferedImage.convertFrom(buffered, rgb, true); ColorHsv.rgbToHsv(rgb, hsv); GHistogramFeatureOps.histogram(hsv.getBand(0), 0, 2*Math.PI,histogramHue); GHistogramFeatureOps.histogram(hsv.getBand(1), 0, 1, histogramValue); // need to combine them into a single descriptor for processing later on TupleDesc_F64 imageHist = UtilFeature.combine(histogramList,null); UtilFeature.normalizeL2(imageHist); // normalize so that image size doesn't matter points.add(imageHist.value); } return points; }
java
public static List<double[]> independentHueSat( List<File> images ) { List<double[]> points = new ArrayList<>(); // The number of bins is an important parameter. Try adjusting it TupleDesc_F64 histogramHue = new TupleDesc_F64(30); TupleDesc_F64 histogramValue = new TupleDesc_F64(30); List<TupleDesc_F64> histogramList = new ArrayList<>(); histogramList.add(histogramHue); histogramList.add(histogramValue); Planar<GrayF32> rgb = new Planar<>(GrayF32.class,1,1,3); Planar<GrayF32> hsv = new Planar<>(GrayF32.class,1,1,3); for( File f : images ) { BufferedImage buffered = UtilImageIO.loadImage(f.getPath()); if( buffered == null ) throw new RuntimeException("Can't load image!"); rgb.reshape(buffered.getWidth(), buffered.getHeight()); hsv.reshape(buffered.getWidth(), buffered.getHeight()); ConvertBufferedImage.convertFrom(buffered, rgb, true); ColorHsv.rgbToHsv(rgb, hsv); GHistogramFeatureOps.histogram(hsv.getBand(0), 0, 2*Math.PI,histogramHue); GHistogramFeatureOps.histogram(hsv.getBand(1), 0, 1, histogramValue); // need to combine them into a single descriptor for processing later on TupleDesc_F64 imageHist = UtilFeature.combine(histogramList,null); UtilFeature.normalizeL2(imageHist); // normalize so that image size doesn't matter points.add(imageHist.value); } return points; }
[ "public", "static", "List", "<", "double", "[", "]", ">", "independentHueSat", "(", "List", "<", "File", ">", "images", ")", "{", "List", "<", "double", "[", "]", ">", "points", "=", "new", "ArrayList", "<>", "(", ")", ";", "// The number of bins is an i...
Computes two independent 1D histograms from hue and saturation. Less affects by sparsity, but can produce worse results since the basic assumption that hue and saturation are decoupled is most of the time false.
[ "Computes", "two", "independent", "1D", "histograms", "from", "hue", "and", "saturation", ".", "Less", "affects", "by", "sparsity", "but", "can", "produce", "worse", "results", "since", "the", "basic", "assumption", "that", "hue", "and", "saturation", "are", "...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/recognition/ExampleColorHistogramLookup.java#L108-L142
train
lessthanoptimal/BoofCV
examples/src/main/java/boofcv/examples/recognition/ExampleColorHistogramLookup.java
ExampleColorHistogramLookup.coupledRGB
public static List<double[]> coupledRGB( List<File> images ) { List<double[]> points = new ArrayList<>(); Planar<GrayF32> rgb = new Planar<>(GrayF32.class,1,1,3); for( File f : images ) { BufferedImage buffered = UtilImageIO.loadImage(f.getPath()); if( buffered == null ) throw new RuntimeException("Can't load image!"); rgb.reshape(buffered.getWidth(), buffered.getHeight()); ConvertBufferedImage.convertFrom(buffered, rgb, true); // The number of bins is an important parameter. Try adjusting it Histogram_F64 histogram = new Histogram_F64(10,10,10); histogram.setRange(0, 0, 255); histogram.setRange(1, 0, 255); histogram.setRange(2, 0, 255); GHistogramFeatureOps.histogram(rgb,histogram); UtilFeature.normalizeL2(histogram); // normalize so that image size doesn't matter points.add(histogram.value); } return points; }
java
public static List<double[]> coupledRGB( List<File> images ) { List<double[]> points = new ArrayList<>(); Planar<GrayF32> rgb = new Planar<>(GrayF32.class,1,1,3); for( File f : images ) { BufferedImage buffered = UtilImageIO.loadImage(f.getPath()); if( buffered == null ) throw new RuntimeException("Can't load image!"); rgb.reshape(buffered.getWidth(), buffered.getHeight()); ConvertBufferedImage.convertFrom(buffered, rgb, true); // The number of bins is an important parameter. Try adjusting it Histogram_F64 histogram = new Histogram_F64(10,10,10); histogram.setRange(0, 0, 255); histogram.setRange(1, 0, 255); histogram.setRange(2, 0, 255); GHistogramFeatureOps.histogram(rgb,histogram); UtilFeature.normalizeL2(histogram); // normalize so that image size doesn't matter points.add(histogram.value); } return points; }
[ "public", "static", "List", "<", "double", "[", "]", ">", "coupledRGB", "(", "List", "<", "File", ">", "images", ")", "{", "List", "<", "double", "[", "]", ">", "points", "=", "new", "ArrayList", "<>", "(", ")", ";", "Planar", "<", "GrayF32", ">", ...
Constructs a 3D histogram using RGB. RGB is a popular color space, but the resulting histogram will depend on lighting conditions and might not produce the accurate results.
[ "Constructs", "a", "3D", "histogram", "using", "RGB", ".", "RGB", "is", "a", "popular", "color", "space", "but", "the", "resulting", "histogram", "will", "depend", "on", "lighting", "conditions", "and", "might", "not", "produce", "the", "accurate", "results", ...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/recognition/ExampleColorHistogramLookup.java#L148-L174
train
lessthanoptimal/BoofCV
examples/src/main/java/boofcv/examples/recognition/ExampleColorHistogramLookup.java
ExampleColorHistogramLookup.histogramGray
public static List<double[]> histogramGray( List<File> images ) { List<double[]> points = new ArrayList<>(); GrayU8 gray = new GrayU8(1,1); for( File f : images ) { BufferedImage buffered = UtilImageIO.loadImage(f.getPath()); if( buffered == null ) throw new RuntimeException("Can't load image!"); gray.reshape(buffered.getWidth(), buffered.getHeight()); ConvertBufferedImage.convertFrom(buffered, gray, true); TupleDesc_F64 imageHist = new TupleDesc_F64(150); HistogramFeatureOps.histogram(gray, 255, imageHist); UtilFeature.normalizeL2(imageHist); // normalize so that image size doesn't matter points.add(imageHist.value); } return points; }
java
public static List<double[]> histogramGray( List<File> images ) { List<double[]> points = new ArrayList<>(); GrayU8 gray = new GrayU8(1,1); for( File f : images ) { BufferedImage buffered = UtilImageIO.loadImage(f.getPath()); if( buffered == null ) throw new RuntimeException("Can't load image!"); gray.reshape(buffered.getWidth(), buffered.getHeight()); ConvertBufferedImage.convertFrom(buffered, gray, true); TupleDesc_F64 imageHist = new TupleDesc_F64(150); HistogramFeatureOps.histogram(gray, 255, imageHist); UtilFeature.normalizeL2(imageHist); // normalize so that image size doesn't matter points.add(imageHist.value); } return points; }
[ "public", "static", "List", "<", "double", "[", "]", ">", "histogramGray", "(", "List", "<", "File", ">", "images", ")", "{", "List", "<", "double", "[", "]", ">", "points", "=", "new", "ArrayList", "<>", "(", ")", ";", "GrayU8", "gray", "=", "new"...
Computes a histogram from the gray scale intensity image alone. Probably the least effective at looking up similar images.
[ "Computes", "a", "histogram", "from", "the", "gray", "scale", "intensity", "image", "alone", ".", "Probably", "the", "least", "effective", "at", "looking", "up", "similar", "images", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/recognition/ExampleColorHistogramLookup.java#L180-L200
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/misc/DiscretizedCircle.java
DiscretizedCircle.imageOffsets
public static int[] imageOffsets(double radius, int imgWidth) { double PI2 = Math.PI * 2.0; double circumference = PI2 * radius; int num = (int) Math.ceil(circumference); num = num - num % 4; double angleStep = PI2 / num; int temp[] = new int[(int) Math.ceil(circumference)]; int i = 0; int prev = 0; for (double ang = 0; ang < PI2; ang += angleStep) { int x = (int) Math.round(Math.cos(ang) * radius); int y = (int) Math.round(Math.sin(ang) * radius); int pixel = y * imgWidth + x; if (pixel != prev) { // System.out.println("i = "+i+" x = "+x+" y = "+y); temp[i++] = pixel; } prev = pixel; } if (i == temp.length) return temp; else { int ret[] = new int[i]; System.arraycopy(temp, 0, ret, 0, i); return ret; } }
java
public static int[] imageOffsets(double radius, int imgWidth) { double PI2 = Math.PI * 2.0; double circumference = PI2 * radius; int num = (int) Math.ceil(circumference); num = num - num % 4; double angleStep = PI2 / num; int temp[] = new int[(int) Math.ceil(circumference)]; int i = 0; int prev = 0; for (double ang = 0; ang < PI2; ang += angleStep) { int x = (int) Math.round(Math.cos(ang) * radius); int y = (int) Math.round(Math.sin(ang) * radius); int pixel = y * imgWidth + x; if (pixel != prev) { // System.out.println("i = "+i+" x = "+x+" y = "+y); temp[i++] = pixel; } prev = pixel; } if (i == temp.length) return temp; else { int ret[] = new int[i]; System.arraycopy(temp, 0, ret, 0, i); return ret; } }
[ "public", "static", "int", "[", "]", "imageOffsets", "(", "double", "radius", ",", "int", "imgWidth", ")", "{", "double", "PI2", "=", "Math", ".", "PI", "*", "2.0", ";", "double", "circumference", "=", "PI2", "*", "radius", ";", "int", "num", "=", "(...
Computes the offsets for a discretized circle of the specified radius for an image with the specified width. @param radius The radius of the circle in pixels. @param imgWidth The row step of the image @return A list of offsets that describe the circle
[ "Computes", "the", "offsets", "for", "a", "discretized", "circle", "of", "the", "specified", "radius", "for", "an", "image", "with", "the", "specified", "width", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/misc/DiscretizedCircle.java#L36-L74
train
lessthanoptimal/BoofCV
examples/src/main/java/boofcv/examples/features/ExampleDetectDescribe.java
ExampleDetectDescribe.createFromPremade
public static <T extends ImageGray<T>, TD extends TupleDesc> DetectDescribePoint<T, TD> createFromPremade( Class<T> imageType ) { return (DetectDescribePoint)FactoryDetectDescribe.surfStable( new ConfigFastHessian(1, 2, 200, 1, 9, 4, 4), null,null, imageType); // return (DetectDescribePoint)FactoryDetectDescribe.sift(new ConfigCompleteSift(-1,5,300)); }
java
public static <T extends ImageGray<T>, TD extends TupleDesc> DetectDescribePoint<T, TD> createFromPremade( Class<T> imageType ) { return (DetectDescribePoint)FactoryDetectDescribe.surfStable( new ConfigFastHessian(1, 2, 200, 1, 9, 4, 4), null,null, imageType); // return (DetectDescribePoint)FactoryDetectDescribe.sift(new ConfigCompleteSift(-1,5,300)); }
[ "public", "static", "<", "T", "extends", "ImageGray", "<", "T", ">", ",", "TD", "extends", "TupleDesc", ">", "DetectDescribePoint", "<", "T", ",", "TD", ">", "createFromPremade", "(", "Class", "<", "T", ">", "imageType", ")", "{", "return", "(", "DetectD...
For some features, there are pre-made implementations of DetectDescribePoint. This has only been done in situations where there was a performance advantage or that it was a very common combination.
[ "For", "some", "features", "there", "are", "pre", "-", "made", "implementations", "of", "DetectDescribePoint", ".", "This", "has", "only", "been", "done", "in", "situations", "where", "there", "was", "a", "performance", "advantage", "or", "that", "it", "was", ...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/features/ExampleDetectDescribe.java#L61-L66
train
lessthanoptimal/BoofCV
examples/src/main/java/boofcv/examples/features/ExampleDetectDescribe.java
ExampleDetectDescribe.createFromComponents
public static <T extends ImageGray<T>, TD extends TupleDesc> DetectDescribePoint<T, TD> createFromComponents( Class<T> imageType ) { // create a corner detector Class derivType = GImageDerivativeOps.getDerivativeType(imageType); GeneralFeatureDetector corner = FactoryDetectPoint.createShiTomasi(new ConfigGeneralDetector(1000,5,1), null, derivType); InterestPointDetector detector = FactoryInterestPoint.wrapPoint(corner, 1, imageType, derivType); // describe points using BRIEF DescribeRegionPoint describe = FactoryDescribeRegionPoint.brief(new ConfigBrief(true), imageType); // Combine together. // NOTE: orientation will not be estimated return FactoryDetectDescribe.fuseTogether(detector, null, describe); }
java
public static <T extends ImageGray<T>, TD extends TupleDesc> DetectDescribePoint<T, TD> createFromComponents( Class<T> imageType ) { // create a corner detector Class derivType = GImageDerivativeOps.getDerivativeType(imageType); GeneralFeatureDetector corner = FactoryDetectPoint.createShiTomasi(new ConfigGeneralDetector(1000,5,1), null, derivType); InterestPointDetector detector = FactoryInterestPoint.wrapPoint(corner, 1, imageType, derivType); // describe points using BRIEF DescribeRegionPoint describe = FactoryDescribeRegionPoint.brief(new ConfigBrief(true), imageType); // Combine together. // NOTE: orientation will not be estimated return FactoryDetectDescribe.fuseTogether(detector, null, describe); }
[ "public", "static", "<", "T", "extends", "ImageGray", "<", "T", ">", ",", "TD", "extends", "TupleDesc", ">", "DetectDescribePoint", "<", "T", ",", "TD", ">", "createFromComponents", "(", "Class", "<", "T", ">", "imageType", ")", "{", "// create a corner dete...
Any arbitrary implementation of InterestPointDetector, OrientationImage, DescribeRegionPoint can be combined into DetectDescribePoint. The syntax is more complex, but the end result is more flexible. This should only be done if there isn't a pre-made DetectDescribePoint.
[ "Any", "arbitrary", "implementation", "of", "InterestPointDetector", "OrientationImage", "DescribeRegionPoint", "can", "be", "combined", "into", "DetectDescribePoint", ".", "The", "syntax", "is", "more", "complex", "but", "the", "end", "result", "is", "more", "flexibl...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/features/ExampleDetectDescribe.java#L73-L86
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/tracker/meanshift/LocalWeightedHistogramRotRect.java
LocalWeightedHistogramRotRect.computeWeights
protected void computeWeights(int numSamples, double numSigmas) { weights = new float[ numSamples*numSamples ]; float w[] = new float[ numSamples ]; for( int i = 0; i < numSamples; i++ ) { float x = i/(float)(numSamples-1); w[i] = (float) UtilGaussian.computePDF(0, 1, 2f*numSigmas * (x - 0.5f)); } for( int y = 0; y < numSamples; y++ ) { for( int x = 0; x < numSamples; x++ ) { weights[y*numSamples + x] = w[y]*w[x]; } } }
java
protected void computeWeights(int numSamples, double numSigmas) { weights = new float[ numSamples*numSamples ]; float w[] = new float[ numSamples ]; for( int i = 0; i < numSamples; i++ ) { float x = i/(float)(numSamples-1); w[i] = (float) UtilGaussian.computePDF(0, 1, 2f*numSigmas * (x - 0.5f)); } for( int y = 0; y < numSamples; y++ ) { for( int x = 0; x < numSamples; x++ ) { weights[y*numSamples + x] = w[y]*w[x]; } } }
[ "protected", "void", "computeWeights", "(", "int", "numSamples", ",", "double", "numSigmas", ")", "{", "weights", "=", "new", "float", "[", "numSamples", "*", "numSamples", "]", ";", "float", "w", "[", "]", "=", "new", "float", "[", "numSamples", "]", ";...
compute the weights by convolving 1D gaussian kernel
[ "compute", "the", "weights", "by", "convolving", "1D", "gaussian", "kernel" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/meanshift/LocalWeightedHistogramRotRect.java#L97-L111
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/tracker/meanshift/LocalWeightedHistogramRotRect.java
LocalWeightedHistogramRotRect.createSamplePoints
protected void createSamplePoints(int numSamples) { for( int y = 0; y < numSamples; y++ ) { float regionY = (y/(numSamples-1.0f) - 0.5f); for( int x = 0; x < numSamples; x++ ) { float regionX = (x/(numSamples-1.0f) - 0.5f); samplePts.add( new Point2D_F32(regionX,regionY)); } } }
java
protected void createSamplePoints(int numSamples) { for( int y = 0; y < numSamples; y++ ) { float regionY = (y/(numSamples-1.0f) - 0.5f); for( int x = 0; x < numSamples; x++ ) { float regionX = (x/(numSamples-1.0f) - 0.5f); samplePts.add( new Point2D_F32(regionX,regionY)); } } }
[ "protected", "void", "createSamplePoints", "(", "int", "numSamples", ")", "{", "for", "(", "int", "y", "=", "0", ";", "y", "<", "numSamples", ";", "y", "++", ")", "{", "float", "regionY", "=", "(", "y", "/", "(", "numSamples", "-", "1.0f", ")", "-"...
create the list of points in square coordinates that it will sample. values will range from -0.5 to 0.5 along each axis.
[ "create", "the", "list", "of", "points", "in", "square", "coordinates", "that", "it", "will", "sample", ".", "values", "will", "range", "from", "-", "0", ".", "5", "to", "0", ".", "5", "along", "each", "axis", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/meanshift/LocalWeightedHistogramRotRect.java#L117-L126
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/tracker/meanshift/LocalWeightedHistogramRotRect.java
LocalWeightedHistogramRotRect.computeHistogramInside
protected void computeHistogramInside( RectangleRotate_F32 region) { for( int i = 0; i < samplePts.size(); i++ ) { Point2D_F32 p = samplePts.get(i); squareToImageSample(p.x, p.y, region); interpolate.get_fast(imageX,imageY,value); int indexHistogram = computeHistogramBin(value); sampleHistIndex[ i ] = indexHistogram; histogram[indexHistogram] += weights[i]; } }
java
protected void computeHistogramInside( RectangleRotate_F32 region) { for( int i = 0; i < samplePts.size(); i++ ) { Point2D_F32 p = samplePts.get(i); squareToImageSample(p.x, p.y, region); interpolate.get_fast(imageX,imageY,value); int indexHistogram = computeHistogramBin(value); sampleHistIndex[ i ] = indexHistogram; histogram[indexHistogram] += weights[i]; } }
[ "protected", "void", "computeHistogramInside", "(", "RectangleRotate_F32", "region", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "samplePts", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Point2D_F32", "p", "=", "samplePts", ".", "ge...
Computes the histogram quickly inside the image
[ "Computes", "the", "histogram", "quickly", "inside", "the", "image" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/meanshift/LocalWeightedHistogramRotRect.java#L158-L171
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/tracker/meanshift/LocalWeightedHistogramRotRect.java
LocalWeightedHistogramRotRect.computeHistogramBorder
protected void computeHistogramBorder(T image, RectangleRotate_F32 region) { for( int i = 0; i < samplePts.size(); i++ ) { Point2D_F32 p = samplePts.get(i); squareToImageSample(p.x, p.y, region); // make sure its inside the image if( !BoofMiscOps.checkInside(image, imageX, imageY)) { sampleHistIndex[ i ] = -1; } else { // use the slower interpolation which can handle the border interpolate.get(imageX, imageY, value); int indexHistogram = computeHistogramBin(value); sampleHistIndex[ i ] = indexHistogram; histogram[indexHistogram] += weights[i]; } } }
java
protected void computeHistogramBorder(T image, RectangleRotate_F32 region) { for( int i = 0; i < samplePts.size(); i++ ) { Point2D_F32 p = samplePts.get(i); squareToImageSample(p.x, p.y, region); // make sure its inside the image if( !BoofMiscOps.checkInside(image, imageX, imageY)) { sampleHistIndex[ i ] = -1; } else { // use the slower interpolation which can handle the border interpolate.get(imageX, imageY, value); int indexHistogram = computeHistogramBin(value); sampleHistIndex[ i ] = indexHistogram; histogram[indexHistogram] += weights[i]; } } }
[ "protected", "void", "computeHistogramBorder", "(", "T", "image", ",", "RectangleRotate_F32", "region", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "samplePts", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Point2D_F32", "p", "=", ...
Computes the histogram and skips pixels which are outside the image border
[ "Computes", "the", "histogram", "and", "skips", "pixels", "which", "are", "outside", "the", "image", "border" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/meanshift/LocalWeightedHistogramRotRect.java#L176-L195
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/tracker/meanshift/LocalWeightedHistogramRotRect.java
LocalWeightedHistogramRotRect.computeHistogramBin
protected int computeHistogramBin( float value[] ) { int indexHistogram = 0; int binStride = 1; for( int bandIndex = 0; bandIndex < value.length; bandIndex++ ) { int bin = (int)(numBins*value[bandIndex]/maxPixelValue); indexHistogram += bin*binStride; binStride *= numBins; } return indexHistogram; }
java
protected int computeHistogramBin( float value[] ) { int indexHistogram = 0; int binStride = 1; for( int bandIndex = 0; bandIndex < value.length; bandIndex++ ) { int bin = (int)(numBins*value[bandIndex]/maxPixelValue); indexHistogram += bin*binStride; binStride *= numBins; } return indexHistogram; }
[ "protected", "int", "computeHistogramBin", "(", "float", "value", "[", "]", ")", "{", "int", "indexHistogram", "=", "0", ";", "int", "binStride", "=", "1", ";", "for", "(", "int", "bandIndex", "=", "0", ";", "bandIndex", "<", "value", ".", "length", ";...
Given the value of a pixel, compute which bin in the histogram it belongs in
[ "Given", "the", "value", "of", "a", "pixel", "compute", "which", "bin", "in", "the", "histogram", "it", "belongs", "in" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/meanshift/LocalWeightedHistogramRotRect.java#L200-L210
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/tracker/meanshift/LocalWeightedHistogramRotRect.java
LocalWeightedHistogramRotRect.isInFastBounds
protected boolean isInFastBounds(RectangleRotate_F32 region) { squareToImageSample(-0.5f, -0.5f, region); if( !interpolate.isInFastBounds(imageX, imageY)) return false; squareToImageSample(-0.5f, 0.5f, region); if( !interpolate.isInFastBounds(imageX, imageY)) return false; squareToImageSample(0.5f, 0.5f, region); if( !interpolate.isInFastBounds(imageX, imageY)) return false; squareToImageSample(0.5f, -0.5f, region); if( !interpolate.isInFastBounds(imageX, imageY)) return false; return true; }
java
protected boolean isInFastBounds(RectangleRotate_F32 region) { squareToImageSample(-0.5f, -0.5f, region); if( !interpolate.isInFastBounds(imageX, imageY)) return false; squareToImageSample(-0.5f, 0.5f, region); if( !interpolate.isInFastBounds(imageX, imageY)) return false; squareToImageSample(0.5f, 0.5f, region); if( !interpolate.isInFastBounds(imageX, imageY)) return false; squareToImageSample(0.5f, -0.5f, region); if( !interpolate.isInFastBounds(imageX, imageY)) return false; return true; }
[ "protected", "boolean", "isInFastBounds", "(", "RectangleRotate_F32", "region", ")", "{", "squareToImageSample", "(", "-", "0.5f", ",", "-", "0.5f", ",", "region", ")", ";", "if", "(", "!", "interpolate", ".", "isInFastBounds", "(", "imageX", ",", "imageY", ...
Checks to see if the region can be sampled using the fast algorithm
[ "Checks", "to", "see", "if", "the", "region", "can", "be", "sampled", "using", "the", "fast", "algorithm" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/meanshift/LocalWeightedHistogramRotRect.java#L215-L231
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/tracker/meanshift/LocalWeightedHistogramRotRect.java
LocalWeightedHistogramRotRect.squareToImageSample
protected void squareToImageSample(float x, float y, RectangleRotate_F32 region) { // -1 because it starts counting at 0. otherwise width+1 samples are made x *= region.width-1; y *= region.height-1; imageX = x*c - y*s + region.cx; imageY = x*s + y*c + region.cy; }
java
protected void squareToImageSample(float x, float y, RectangleRotate_F32 region) { // -1 because it starts counting at 0. otherwise width+1 samples are made x *= region.width-1; y *= region.height-1; imageX = x*c - y*s + region.cx; imageY = x*s + y*c + region.cy; }
[ "protected", "void", "squareToImageSample", "(", "float", "x", ",", "float", "y", ",", "RectangleRotate_F32", "region", ")", "{", "// -1 because it starts counting at 0. otherwise width+1 samples are made", "x", "*=", "region", ".", "width", "-", "1", ";", "y", "*=",...
Converts a point from square coordinates into image coordinates
[ "Converts", "a", "point", "from", "square", "coordinates", "into", "image", "coordinates" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/meanshift/LocalWeightedHistogramRotRect.java#L246-L253
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/interest/SiftDetector.java
SiftDetector.createSparseDerivatives
private void createSparseDerivatives() { Kernel1D_F32 kernelD = new Kernel1D_F32(new float[]{-1,0,1},3); Kernel1D_F32 kernelDD = KernelMath.convolve1D_F32(kernelD, kernelD); Kernel2D_F32 kernelXY = KernelMath.convolve2D(kernelD, kernelD); derivXX = FactoryConvolveSparse.horizontal1D(GrayF32.class, kernelDD); derivXY = FactoryConvolveSparse.convolve2D(GrayF32.class, kernelXY); derivYY = FactoryConvolveSparse.vertical1D(GrayF32.class, kernelDD); ImageBorder<GrayF32> border = FactoryImageBorder.single(GrayF32.class, BorderType.EXTENDED); derivXX.setImageBorder(border); derivXY.setImageBorder(border); derivYY.setImageBorder(border); }
java
private void createSparseDerivatives() { Kernel1D_F32 kernelD = new Kernel1D_F32(new float[]{-1,0,1},3); Kernel1D_F32 kernelDD = KernelMath.convolve1D_F32(kernelD, kernelD); Kernel2D_F32 kernelXY = KernelMath.convolve2D(kernelD, kernelD); derivXX = FactoryConvolveSparse.horizontal1D(GrayF32.class, kernelDD); derivXY = FactoryConvolveSparse.convolve2D(GrayF32.class, kernelXY); derivYY = FactoryConvolveSparse.vertical1D(GrayF32.class, kernelDD); ImageBorder<GrayF32> border = FactoryImageBorder.single(GrayF32.class, BorderType.EXTENDED); derivXX.setImageBorder(border); derivXY.setImageBorder(border); derivYY.setImageBorder(border); }
[ "private", "void", "createSparseDerivatives", "(", ")", "{", "Kernel1D_F32", "kernelD", "=", "new", "Kernel1D_F32", "(", "new", "float", "[", "]", "{", "-", "1", ",", "0", ",", "1", "}", ",", "3", ")", ";", "Kernel1D_F32", "kernelDD", "=", "KernelMath", ...
Define sparse image derivative operators.
[ "Define", "sparse", "image", "derivative", "operators", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/interest/SiftDetector.java#L143-L158
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/interest/SiftDetector.java
SiftDetector.process
public void process( GrayF32 input ) { scaleSpace.initialize(input); detections.reset(); do { // scale from octave to input image pixelScaleToInput = scaleSpace.pixelScaleCurrentToInput(); // detect features in the image for (int j = 1; j < scaleSpace.getNumScales()+1; j++) { // not really sure how to compute the scale for features found at a particular DoG image // using the average resulted in less visually appealing circles in a test image sigmaLower = scaleSpace.computeSigmaScale( j - 1); sigmaTarget = scaleSpace.computeSigmaScale( j ); sigmaUpper = scaleSpace.computeSigmaScale( j + 1); // grab the local DoG scale space images dogLower = scaleSpace.getDifferenceOfGaussian(j-1); dogTarget = scaleSpace.getDifferenceOfGaussian(j ); dogUpper = scaleSpace.getDifferenceOfGaussian(j+1); detectFeatures(j); } } while( scaleSpace.computeNextOctave() ); }
java
public void process( GrayF32 input ) { scaleSpace.initialize(input); detections.reset(); do { // scale from octave to input image pixelScaleToInput = scaleSpace.pixelScaleCurrentToInput(); // detect features in the image for (int j = 1; j < scaleSpace.getNumScales()+1; j++) { // not really sure how to compute the scale for features found at a particular DoG image // using the average resulted in less visually appealing circles in a test image sigmaLower = scaleSpace.computeSigmaScale( j - 1); sigmaTarget = scaleSpace.computeSigmaScale( j ); sigmaUpper = scaleSpace.computeSigmaScale( j + 1); // grab the local DoG scale space images dogLower = scaleSpace.getDifferenceOfGaussian(j-1); dogTarget = scaleSpace.getDifferenceOfGaussian(j ); dogUpper = scaleSpace.getDifferenceOfGaussian(j+1); detectFeatures(j); } } while( scaleSpace.computeNextOctave() ); }
[ "public", "void", "process", "(", "GrayF32", "input", ")", "{", "scaleSpace", ".", "initialize", "(", "input", ")", ";", "detections", ".", "reset", "(", ")", ";", "do", "{", "// scale from octave to input image", "pixelScaleToInput", "=", "scaleSpace", ".", "...
Detects SIFT features inside the input image @param input Input image. Not modified.
[ "Detects", "SIFT", "features", "inside", "the", "input", "image" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/interest/SiftDetector.java#L165-L191
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/interest/SiftDetector.java
SiftDetector.detectFeatures
protected void detectFeatures( int scaleIndex ) { extractor.process(dogTarget); FastQueue<NonMaxLimiter.LocalExtreme> found = extractor.getLocalExtreme(); derivXX.setImage(dogTarget); derivXY.setImage(dogTarget); derivYY.setImage(dogTarget); for (int i = 0; i < found.size; i++) { NonMaxLimiter.LocalExtreme e = found.get(i); if( e.max ) { if( isScaleSpaceExtremum(e.location.x, e.location.y, e.getValue(), 1f)) { processFeatureCandidate(e.location.x,e.location.y,e.getValue(),e.max); } } else if( isScaleSpaceExtremum(e.location.x, e.location.y, e.getValue(), -1f)) { processFeatureCandidate(e.location.x,e.location.y,e.getValue(),e.max); } } }
java
protected void detectFeatures( int scaleIndex ) { extractor.process(dogTarget); FastQueue<NonMaxLimiter.LocalExtreme> found = extractor.getLocalExtreme(); derivXX.setImage(dogTarget); derivXY.setImage(dogTarget); derivYY.setImage(dogTarget); for (int i = 0; i < found.size; i++) { NonMaxLimiter.LocalExtreme e = found.get(i); if( e.max ) { if( isScaleSpaceExtremum(e.location.x, e.location.y, e.getValue(), 1f)) { processFeatureCandidate(e.location.x,e.location.y,e.getValue(),e.max); } } else if( isScaleSpaceExtremum(e.location.x, e.location.y, e.getValue(), -1f)) { processFeatureCandidate(e.location.x,e.location.y,e.getValue(),e.max); } } }
[ "protected", "void", "detectFeatures", "(", "int", "scaleIndex", ")", "{", "extractor", ".", "process", "(", "dogTarget", ")", ";", "FastQueue", "<", "NonMaxLimiter", ".", "LocalExtreme", ">", "found", "=", "extractor", ".", "getLocalExtreme", "(", ")", ";", ...
Detect features inside the Difference-of-Gaussian image at the current scale @param scaleIndex Which scale in the octave is it detecting features inside up. Primarily provided here for use in child classes.
[ "Detect", "features", "inside", "the", "Difference", "-", "of", "-", "Gaussian", "image", "at", "the", "current", "scale" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/interest/SiftDetector.java#L199-L218
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/interest/SiftDetector.java
SiftDetector.isScaleSpaceExtremum
boolean isScaleSpaceExtremum(int c_x, int c_y, float value, float signAdj) { if( c_x <= 1 || c_y <= 1 || c_x >= dogLower.width-1 || c_y >= dogLower.height-1) return false; float v; value *= signAdj; for( int y = -1; y <= 1; y++ ) { for( int x = -1; x <= 1; x++ ) { v = dogLower.unsafe_get(c_x+x,c_y+y); if( v*signAdj >= value ) return false; v = dogUpper.unsafe_get(c_x+x,c_y+y); if( v*signAdj >= value ) return false; } } return true; }
java
boolean isScaleSpaceExtremum(int c_x, int c_y, float value, float signAdj) { if( c_x <= 1 || c_y <= 1 || c_x >= dogLower.width-1 || c_y >= dogLower.height-1) return false; float v; value *= signAdj; for( int y = -1; y <= 1; y++ ) { for( int x = -1; x <= 1; x++ ) { v = dogLower.unsafe_get(c_x+x,c_y+y); if( v*signAdj >= value ) return false; v = dogUpper.unsafe_get(c_x+x,c_y+y); if( v*signAdj >= value ) return false; } } return true; }
[ "boolean", "isScaleSpaceExtremum", "(", "int", "c_x", ",", "int", "c_y", ",", "float", "value", ",", "float", "signAdj", ")", "{", "if", "(", "c_x", "<=", "1", "||", "c_y", "<=", "1", "||", "c_x", ">=", "dogLower", ".", "width", "-", "1", "||", "c_...
See if the point is a local extremum in scale-space above and below. @param c_x x-coordinate of extremum @param c_y y-coordinate of extremum @param value The maximum value it is checking @param signAdj Adjust the sign so that it can check for maximums @return true if its a local extremum
[ "See", "if", "the", "point", "is", "a", "local", "extremum", "in", "scale", "-", "space", "above", "and", "below", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/interest/SiftDetector.java#L229-L249
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/distort/impl/DistortSupport.java
DistortSupport.transformScale
public static PixelTransformAffine_F32 transformScale(ImageBase from, ImageBase to, PixelTransformAffine_F32 distort) { if( distort == null ) distort = new PixelTransformAffine_F32(); float scaleX = (float)(to.width)/(float)(from.width); float scaleY = (float)(to.height)/(float)(from.height); Affine2D_F32 affine = distort.getModel(); affine.set(scaleX,0,0,scaleY,0,0); return distort; }
java
public static PixelTransformAffine_F32 transformScale(ImageBase from, ImageBase to, PixelTransformAffine_F32 distort) { if( distort == null ) distort = new PixelTransformAffine_F32(); float scaleX = (float)(to.width)/(float)(from.width); float scaleY = (float)(to.height)/(float)(from.height); Affine2D_F32 affine = distort.getModel(); affine.set(scaleX,0,0,scaleY,0,0); return distort; }
[ "public", "static", "PixelTransformAffine_F32", "transformScale", "(", "ImageBase", "from", ",", "ImageBase", "to", ",", "PixelTransformAffine_F32", "distort", ")", "{", "if", "(", "distort", "==", "null", ")", "distort", "=", "new", "PixelTransformAffine_F32", "(",...
Computes a transform which is used to rescale an image. The scale is computed directly from the size of the two input images and independently scales the x and y axises.
[ "Computes", "a", "transform", "which", "is", "used", "to", "rescale", "an", "image", ".", "The", "scale", "is", "computed", "directly", "from", "the", "size", "of", "the", "two", "input", "images", "and", "independently", "scales", "the", "x", "and", "y", ...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/distort/impl/DistortSupport.java#L47-L60
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/f/FundamentalLinear.java
FundamentalLinear.projectOntoEssential
protected boolean projectOntoEssential( DMatrixRMaj E ) { if( !svdConstraints.decompose(E) ) { return false; } svdV = svdConstraints.getV(svdV,false); svdU = svdConstraints.getU(svdU,false); svdS = svdConstraints.getW(svdS); SingularOps_DDRM.descendingOrder(svdU, false, svdS, svdV, false); // project it into essential space // the scale factor is arbitrary, but the first two singular values need // to be the same. so just set them to one svdS.unsafe_set(0, 0, 1); svdS.unsafe_set(1, 1, 1); svdS.unsafe_set(2, 2, 0); // recompute F CommonOps_DDRM.mult(svdU, svdS, temp0); CommonOps_DDRM.multTransB(temp0,svdV, E); return true; }
java
protected boolean projectOntoEssential( DMatrixRMaj E ) { if( !svdConstraints.decompose(E) ) { return false; } svdV = svdConstraints.getV(svdV,false); svdU = svdConstraints.getU(svdU,false); svdS = svdConstraints.getW(svdS); SingularOps_DDRM.descendingOrder(svdU, false, svdS, svdV, false); // project it into essential space // the scale factor is arbitrary, but the first two singular values need // to be the same. so just set them to one svdS.unsafe_set(0, 0, 1); svdS.unsafe_set(1, 1, 1); svdS.unsafe_set(2, 2, 0); // recompute F CommonOps_DDRM.mult(svdU, svdS, temp0); CommonOps_DDRM.multTransB(temp0,svdV, E); return true; }
[ "protected", "boolean", "projectOntoEssential", "(", "DMatrixRMaj", "E", ")", "{", "if", "(", "!", "svdConstraints", ".", "decompose", "(", "E", ")", ")", "{", "return", "false", ";", "}", "svdV", "=", "svdConstraints", ".", "getV", "(", "svdV", ",", "fa...
Projects the found estimate of E onto essential space. @return true if svd returned true.
[ "Projects", "the", "found", "estimate", "of", "E", "onto", "essential", "space", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/f/FundamentalLinear.java#L84-L106
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/f/FundamentalLinear.java
FundamentalLinear.projectOntoFundamentalSpace
protected boolean projectOntoFundamentalSpace( DMatrixRMaj F ) { if( !svdConstraints.decompose(F) ) { return false; } svdV = svdConstraints.getV(svdV,false); svdU = svdConstraints.getU(svdU,false); svdS = svdConstraints.getW(svdS); SingularOps_DDRM.descendingOrder(svdU, false, svdS, svdV, false); // the smallest singular value needs to be set to zero, unlike svdS.set(2, 2, 0); // recompute F CommonOps_DDRM.mult(svdU, svdS, temp0); CommonOps_DDRM.multTransB(temp0,svdV, F); return true; }
java
protected boolean projectOntoFundamentalSpace( DMatrixRMaj F ) { if( !svdConstraints.decompose(F) ) { return false; } svdV = svdConstraints.getV(svdV,false); svdU = svdConstraints.getU(svdU,false); svdS = svdConstraints.getW(svdS); SingularOps_DDRM.descendingOrder(svdU, false, svdS, svdV, false); // the smallest singular value needs to be set to zero, unlike svdS.set(2, 2, 0); // recompute F CommonOps_DDRM.mult(svdU, svdS, temp0); CommonOps_DDRM.multTransB(temp0,svdV, F); return true; }
[ "protected", "boolean", "projectOntoFundamentalSpace", "(", "DMatrixRMaj", "F", ")", "{", "if", "(", "!", "svdConstraints", ".", "decompose", "(", "F", ")", ")", "{", "return", "false", ";", "}", "svdV", "=", "svdConstraints", ".", "getV", "(", "svdV", ","...
Projects the found estimate of F onto Fundamental space. @return true if svd returned true.
[ "Projects", "the", "found", "estimate", "of", "F", "onto", "Fundamental", "space", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/f/FundamentalLinear.java#L113-L131
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldFernClassifier.java
TldFernClassifier.learnFern
public void learnFern(boolean positive, ImageRectangle r) { float rectWidth = r.getWidth(); float rectHeight = r.getHeight(); float c_x = r.x0+(rectWidth-1)/2f; float c_y = r.y0+(rectHeight-1)/2f; for( int i = 0; i < ferns.length; i++ ) { // first learn it with no noise int value = computeFernValue(c_x, c_y, rectWidth, rectHeight,ferns[i]); TldFernFeature f = managers[i].lookupFern(value); increment(f,positive); } }
java
public void learnFern(boolean positive, ImageRectangle r) { float rectWidth = r.getWidth(); float rectHeight = r.getHeight(); float c_x = r.x0+(rectWidth-1)/2f; float c_y = r.y0+(rectHeight-1)/2f; for( int i = 0; i < ferns.length; i++ ) { // first learn it with no noise int value = computeFernValue(c_x, c_y, rectWidth, rectHeight,ferns[i]); TldFernFeature f = managers[i].lookupFern(value); increment(f,positive); } }
[ "public", "void", "learnFern", "(", "boolean", "positive", ",", "ImageRectangle", "r", ")", "{", "float", "rectWidth", "=", "r", ".", "getWidth", "(", ")", ";", "float", "rectHeight", "=", "r", ".", "getHeight", "(", ")", ";", "float", "c_x", "=", "r",...
Learns a fern from the specified region. No noise is added.
[ "Learns", "a", "fern", "from", "the", "specified", "region", ".", "No", "noise", "is", "added", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldFernClassifier.java#L106-L121
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldFernClassifier.java
TldFernClassifier.learnFernNoise
public void learnFernNoise(boolean positive, ImageRectangle r) { float rectWidth = r.getWidth(); float rectHeight = r.getHeight(); float c_x = r.x0+(rectWidth-1)/2.0f; float c_y = r.y0+(rectHeight-1)/2.0f; for( int i = 0; i < ferns.length; i++ ) { // first learn it with no noise int value = computeFernValue(c_x, c_y, rectWidth, rectHeight,ferns[i]); TldFernFeature f = managers[i].lookupFern(value); increment(f,positive); for( int j = 0; j < numLearnRandom; j++ ) { value = computeFernValueRand(c_x, c_y, rectWidth, rectHeight,ferns[i]); f = managers[i].lookupFern(value); increment(f,positive); } } }
java
public void learnFernNoise(boolean positive, ImageRectangle r) { float rectWidth = r.getWidth(); float rectHeight = r.getHeight(); float c_x = r.x0+(rectWidth-1)/2.0f; float c_y = r.y0+(rectHeight-1)/2.0f; for( int i = 0; i < ferns.length; i++ ) { // first learn it with no noise int value = computeFernValue(c_x, c_y, rectWidth, rectHeight,ferns[i]); TldFernFeature f = managers[i].lookupFern(value); increment(f,positive); for( int j = 0; j < numLearnRandom; j++ ) { value = computeFernValueRand(c_x, c_y, rectWidth, rectHeight,ferns[i]); f = managers[i].lookupFern(value); increment(f,positive); } } }
[ "public", "void", "learnFernNoise", "(", "boolean", "positive", ",", "ImageRectangle", "r", ")", "{", "float", "rectWidth", "=", "r", ".", "getWidth", "(", ")", ";", "float", "rectHeight", "=", "r", ".", "getHeight", "(", ")", ";", "float", "c_x", "=", ...
Computes the value for each fern inside the region and update's their P and N value. Noise is added to the image measurements to take in account the variability.
[ "Computes", "the", "value", "for", "each", "fern", "inside", "the", "region", "and", "update", "s", "their", "P", "and", "N", "value", ".", "Noise", "is", "added", "to", "the", "image", "measurements", "to", "take", "in", "account", "the", "variability", ...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldFernClassifier.java#L127-L148
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldFernClassifier.java
TldFernClassifier.increment
private void increment( TldFernFeature f , boolean positive ) { if( positive ) { f.incrementP(); if( f.numP > maxP ) maxP = f.numP; } else { f.incrementN(); if( f.numN > maxN ) maxN = f.numN; } }
java
private void increment( TldFernFeature f , boolean positive ) { if( positive ) { f.incrementP(); if( f.numP > maxP ) maxP = f.numP; } else { f.incrementN(); if( f.numN > maxN ) maxN = f.numN; } }
[ "private", "void", "increment", "(", "TldFernFeature", "f", ",", "boolean", "positive", ")", "{", "if", "(", "positive", ")", "{", "f", ".", "incrementP", "(", ")", ";", "if", "(", "f", ".", "numP", ">", "maxP", ")", "maxP", "=", "f", ".", "numP", ...
Increments the P and N value for a fern. Also updates the maxP and maxN statistics so that it knows when to re-normalize data structures.
[ "Increments", "the", "P", "and", "N", "value", "for", "a", "fern", ".", "Also", "updates", "the", "maxP", "and", "maxN", "statistics", "so", "that", "it", "knows", "when", "to", "re", "-", "normalize", "data", "structures", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldFernClassifier.java#L154-L164
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldFernClassifier.java
TldFernClassifier.lookupFernPN
public boolean lookupFernPN( TldRegionFernInfo info ) { ImageRectangle r = info.r; float rectWidth = r.getWidth(); float rectHeight = r.getHeight(); float c_x = r.x0+(rectWidth-1)/2.0f; float c_y = r.y0+(rectHeight-1)/2.0f; int sumP = 0; int sumN = 0; for( int i = 0; i < ferns.length; i++ ) { TldFernDescription fern = ferns[i]; int value = computeFernValue(c_x, c_y, rectWidth, rectHeight, fern); TldFernFeature f = managers[i].table[value]; if( f != null ) { sumP += f.numP; sumN += f.numN; } } info.sumP = sumP; info.sumN = sumN; return sumN != 0 || sumP != 0; }
java
public boolean lookupFernPN( TldRegionFernInfo info ) { ImageRectangle r = info.r; float rectWidth = r.getWidth(); float rectHeight = r.getHeight(); float c_x = r.x0+(rectWidth-1)/2.0f; float c_y = r.y0+(rectHeight-1)/2.0f; int sumP = 0; int sumN = 0; for( int i = 0; i < ferns.length; i++ ) { TldFernDescription fern = ferns[i]; int value = computeFernValue(c_x, c_y, rectWidth, rectHeight, fern); TldFernFeature f = managers[i].table[value]; if( f != null ) { sumP += f.numP; sumN += f.numN; } } info.sumP = sumP; info.sumN = sumN; return sumN != 0 || sumP != 0; }
[ "public", "boolean", "lookupFernPN", "(", "TldRegionFernInfo", "info", ")", "{", "ImageRectangle", "r", "=", "info", ".", "r", ";", "float", "rectWidth", "=", "r", ".", "getWidth", "(", ")", ";", "float", "rectHeight", "=", "r", ".", "getHeight", "(", ")...
For the specified regions, computes the values of each fern inside of it and then retrives their P and N values. The sum of which is stored inside of info. @param info (Input) Location/Rectangle (output) P and N values @return true if a known value for any of the ferns was observed in this region
[ "For", "the", "specified", "regions", "computes", "the", "values", "of", "each", "fern", "inside", "of", "it", "and", "then", "retrives", "their", "P", "and", "N", "values", ".", "The", "sum", "of", "which", "is", "stored", "inside", "of", "info", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldFernClassifier.java#L172-L201
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldFernClassifier.java
TldFernClassifier.computeFernValue
protected int computeFernValue(float c_x, float c_y, float rectWidth , float rectHeight , TldFernDescription fern ) { rectWidth -= 1; rectHeight -= 1; int desc = 0; for( int i = 0; i < fern.pairs.length; i++ ) { Point2D_F32 p_a = fern.pairs[i].a; Point2D_F32 p_b = fern.pairs[i].b; float valA = interpolate.get_fast(c_x + p_a.x * rectWidth, c_y + p_a.y * rectHeight); float valB = interpolate.get_fast(c_x + p_b.x * rectWidth, c_y + p_b.y * rectHeight); desc *= 2; if( valA < valB ) { desc += 1; } } return desc; }
java
protected int computeFernValue(float c_x, float c_y, float rectWidth , float rectHeight , TldFernDescription fern ) { rectWidth -= 1; rectHeight -= 1; int desc = 0; for( int i = 0; i < fern.pairs.length; i++ ) { Point2D_F32 p_a = fern.pairs[i].a; Point2D_F32 p_b = fern.pairs[i].b; float valA = interpolate.get_fast(c_x + p_a.x * rectWidth, c_y + p_a.y * rectHeight); float valB = interpolate.get_fast(c_x + p_b.x * rectWidth, c_y + p_b.y * rectHeight); desc *= 2; if( valA < valB ) { desc += 1; } } return desc; }
[ "protected", "int", "computeFernValue", "(", "float", "c_x", ",", "float", "c_y", ",", "float", "rectWidth", ",", "float", "rectHeight", ",", "TldFernDescription", "fern", ")", "{", "rectWidth", "-=", "1", ";", "rectHeight", "-=", "1", ";", "int", "desc", ...
Computes the value of the specified fern at the specified location in the image.
[ "Computes", "the", "value", "of", "the", "specified", "fern", "at", "the", "specified", "location", "in", "the", "image", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldFernClassifier.java#L206-L227
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldFernClassifier.java
TldFernClassifier.renormalizeP
public void renormalizeP() { int targetMax = maxP/20; for( int i = 0; i < managers.length; i++ ) { TldFernManager m = managers[i]; for( int j = 0; j < m.table.length; j++ ) { TldFernFeature f = m.table[j]; if( f == null ) continue; f.numP = targetMax*f.numP/maxP; } } maxP = targetMax; }
java
public void renormalizeP() { int targetMax = maxP/20; for( int i = 0; i < managers.length; i++ ) { TldFernManager m = managers[i]; for( int j = 0; j < m.table.length; j++ ) { TldFernFeature f = m.table[j]; if( f == null ) continue; f.numP = targetMax*f.numP/maxP; } } maxP = targetMax; }
[ "public", "void", "renormalizeP", "(", ")", "{", "int", "targetMax", "=", "maxP", "/", "20", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "managers", ".", "length", ";", "i", "++", ")", "{", "TldFernManager", "m", "=", "managers", "[", "...
Renormalizes fern.numP to avoid overflow
[ "Renormalizes", "fern", ".", "numP", "to", "avoid", "overflow" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldFernClassifier.java#L261-L274
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldFernClassifier.java
TldFernClassifier.renormalizeN
public void renormalizeN() { int targetMax = maxN/20; for( int i = 0; i < managers.length; i++ ) { TldFernManager m = managers[i]; for( int j = 0; j < m.table.length; j++ ) { TldFernFeature f = m.table[j]; if( f == null ) continue; f.numN = targetMax*f.numN/maxN; } } maxN = targetMax; }
java
public void renormalizeN() { int targetMax = maxN/20; for( int i = 0; i < managers.length; i++ ) { TldFernManager m = managers[i]; for( int j = 0; j < m.table.length; j++ ) { TldFernFeature f = m.table[j]; if( f == null ) continue; f.numN = targetMax*f.numN/maxN; } } maxN = targetMax; }
[ "public", "void", "renormalizeN", "(", ")", "{", "int", "targetMax", "=", "maxN", "/", "20", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "managers", ".", "length", ";", "i", "++", ")", "{", "TldFernManager", "m", "=", "managers", "[", "...
Renormalizes fern.numN to avoid overflow
[ "Renormalizes", "fern", ".", "numN", "to", "avoid", "overflow" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldFernClassifier.java#L279-L292
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/describe/DescribePointSurf.java
DescribePointSurf.describe
public void describe(double x, double y, double angle, double scale, TupleDesc_F64 ret) { double c = Math.cos(angle),s=Math.sin(angle); // By assuming that the entire feature is inside the image faster algorithms can be used // the results are also of dubious value when interacting with the image border. boolean isInBounds = SurfDescribeOps.isInside(ii,x,y, radiusDescriptor,widthSample,scale,c,s); // declare the feature if needed if( ret == null ) ret = new BrightFeature(featureDOF); else if( ret.value.length != featureDOF ) throw new IllegalArgumentException("Provided feature must have "+featureDOF+" values"); gradient.setImage(ii); gradient.setWidth(widthSample*scale); // use a safe method if its along the image border SparseImageGradient gradient = isInBounds ? this.gradient : this.gradientSafe; // extract descriptor features(x, y, c, s, scale, gradient , ret.value); }
java
public void describe(double x, double y, double angle, double scale, TupleDesc_F64 ret) { double c = Math.cos(angle),s=Math.sin(angle); // By assuming that the entire feature is inside the image faster algorithms can be used // the results are also of dubious value when interacting with the image border. boolean isInBounds = SurfDescribeOps.isInside(ii,x,y, radiusDescriptor,widthSample,scale,c,s); // declare the feature if needed if( ret == null ) ret = new BrightFeature(featureDOF); else if( ret.value.length != featureDOF ) throw new IllegalArgumentException("Provided feature must have "+featureDOF+" values"); gradient.setImage(ii); gradient.setWidth(widthSample*scale); // use a safe method if its along the image border SparseImageGradient gradient = isInBounds ? this.gradient : this.gradientSafe; // extract descriptor features(x, y, c, s, scale, gradient , ret.value); }
[ "public", "void", "describe", "(", "double", "x", ",", "double", "y", ",", "double", "angle", ",", "double", "scale", ",", "TupleDesc_F64", "ret", ")", "{", "double", "c", "=", "Math", ".", "cos", "(", "angle", ")", ",", "s", "=", "Math", ".", "sin...
Compute SURF descriptor, but without laplacian sign @param x Location of interest point. @param y Location of interest point. @param angle The angle the feature is pointing at in radians. @param scale Scale of the interest point. Null is returned if the feature goes outside the image border. @param ret storage for the feature. Must have 64 values.
[ "Compute", "SURF", "descriptor", "but", "without", "laplacian", "sign" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/describe/DescribePointSurf.java#L190-L213
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/describe/DescribePointSurf.java
DescribePointSurf.computeLaplaceSign
public boolean computeLaplaceSign(int x, int y, double scale) { int s = (int)Math.ceil(scale); kerXX = DerivativeIntegralImage.kernelDerivXX(9*s,kerXX); kerYY = DerivativeIntegralImage.kernelDerivYY(9*s,kerYY); double lap = GIntegralImageOps.convolveSparse(ii,kerXX,x,y); lap += GIntegralImageOps.convolveSparse(ii,kerYY,x,y); return lap > 0; }
java
public boolean computeLaplaceSign(int x, int y, double scale) { int s = (int)Math.ceil(scale); kerXX = DerivativeIntegralImage.kernelDerivXX(9*s,kerXX); kerYY = DerivativeIntegralImage.kernelDerivYY(9*s,kerYY); double lap = GIntegralImageOps.convolveSparse(ii,kerXX,x,y); lap += GIntegralImageOps.convolveSparse(ii,kerYY,x,y); return lap > 0; }
[ "public", "boolean", "computeLaplaceSign", "(", "int", "x", ",", "int", "y", ",", "double", "scale", ")", "{", "int", "s", "=", "(", "int", ")", "Math", ".", "ceil", "(", "scale", ")", ";", "kerXX", "=", "DerivativeIntegralImage", ".", "kernelDerivXX", ...
Compute the sign of the Laplacian using a sparse convolution. @param x center @param y center @param scale scale of the feature @return true if positive
[ "Compute", "the", "sign", "of", "the", "Laplacian", "using", "a", "sparse", "convolution", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/describe/DescribePointSurf.java#L305-L313
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/factory/feature/detect/line/FactoryDetectLineAlgs.java
FactoryDetectLineAlgs.houghPolar
public static <I extends ImageGray<I>, D extends ImageGray<D>> DetectLineHoughPolar<I,D> houghPolar(ConfigHoughPolar config , Class<I> imageType , Class<D> derivType ) { if( config == null ) throw new IllegalArgumentException("This is no default since minCounts must be specified"); ImageGradient<I,D> gradient = FactoryDerivative.sobel(imageType,derivType); return new DetectLineHoughPolar<>(config.localMaxRadius, config.minCounts, config.resolutionRange, config.resolutionAngle, config.thresholdEdge, config.maxLines, gradient); }
java
public static <I extends ImageGray<I>, D extends ImageGray<D>> DetectLineHoughPolar<I,D> houghPolar(ConfigHoughPolar config , Class<I> imageType , Class<D> derivType ) { if( config == null ) throw new IllegalArgumentException("This is no default since minCounts must be specified"); ImageGradient<I,D> gradient = FactoryDerivative.sobel(imageType,derivType); return new DetectLineHoughPolar<>(config.localMaxRadius, config.minCounts, config.resolutionRange, config.resolutionAngle, config.thresholdEdge, config.maxLines, gradient); }
[ "public", "static", "<", "I", "extends", "ImageGray", "<", "I", ">", ",", "D", "extends", "ImageGray", "<", "D", ">", ">", "DetectLineHoughPolar", "<", "I", ",", "D", ">", "houghPolar", "(", "ConfigHoughPolar", "config", ",", "Class", "<", "I", ">", "i...
Creates a Hough line detector based on polar parametrization. @see DetectLineHoughPolar @param config Configuration for line detector. Can't be null. @param imageType Type of single band input image. @param derivType Image derivative type. @param <I> Input image type. @param <D> Image derivative type. @return Line detector.
[ "Creates", "a", "Hough", "line", "detector", "based", "on", "polar", "parametrization", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/factory/feature/detect/line/FactoryDetectLineAlgs.java#L161-L173
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/binary/VisualizeBinaryData.java
VisualizeBinaryData.renderContours
public static BufferedImage renderContours(List<Contour> contours , int colorExternal, int colorInternal , int width , int height , BufferedImage out) { if( out == null ) { out = new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB); } else { Graphics2D g2 = out.createGraphics(); g2.setColor(Color.BLACK); g2.fillRect(0,0,width,height); } for( Contour c : contours ) { for(Point2D_I32 p : c.external ) { out.setRGB(p.x,p.y,colorExternal); } for( List<Point2D_I32> l : c.internal ) { for( Point2D_I32 p : l ) { out.setRGB(p.x,p.y,colorInternal); } } } return out; }
java
public static BufferedImage renderContours(List<Contour> contours , int colorExternal, int colorInternal , int width , int height , BufferedImage out) { if( out == null ) { out = new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB); } else { Graphics2D g2 = out.createGraphics(); g2.setColor(Color.BLACK); g2.fillRect(0,0,width,height); } for( Contour c : contours ) { for(Point2D_I32 p : c.external ) { out.setRGB(p.x,p.y,colorExternal); } for( List<Point2D_I32> l : c.internal ) { for( Point2D_I32 p : l ) { out.setRGB(p.x,p.y,colorInternal); } } } return out; }
[ "public", "static", "BufferedImage", "renderContours", "(", "List", "<", "Contour", ">", "contours", ",", "int", "colorExternal", ",", "int", "colorInternal", ",", "int", "width", ",", "int", "height", ",", "BufferedImage", "out", ")", "{", "if", "(", "out",...
Draws contours. Internal and external contours are different user specified colors. @param contours List of contours @param colorExternal RGB color @param colorInternal RGB color @param width Image width @param height Image height @param out (Optional) storage for output image @return Rendered contours
[ "Draws", "contours", ".", "Internal", "and", "external", "contours", "are", "different", "user", "specified", "colors", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/binary/VisualizeBinaryData.java#L77-L100
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/binary/VisualizeBinaryData.java
VisualizeBinaryData.render
public static void render(List<Contour> contours , int colors[] , BufferedImage out) { colors = checkColors(colors,contours.size()); for( int i = 0; i < contours.size(); i++ ) { Contour c = contours.get(i); int color = colors[i]; for(Point2D_I32 p : c.external ) { out.setRGB(p.x,p.y,color); } } }
java
public static void render(List<Contour> contours , int colors[] , BufferedImage out) { colors = checkColors(colors,contours.size()); for( int i = 0; i < contours.size(); i++ ) { Contour c = contours.get(i); int color = colors[i]; for(Point2D_I32 p : c.external ) { out.setRGB(p.x,p.y,color); } } }
[ "public", "static", "void", "render", "(", "List", "<", "Contour", ">", "contours", ",", "int", "colors", "[", "]", ",", "BufferedImage", "out", ")", "{", "colors", "=", "checkColors", "(", "colors", ",", "contours", ".", "size", "(", ")", ")", ";", ...
Renders only the external contours. Each contour is individually colored as specified by 'colors' @param contours List of contours @param colors List of RGB colors for each element in contours. If null then random colors will be used. @param out (Optional) Storage for output
[ "Renders", "only", "the", "external", "contours", ".", "Each", "contour", "is", "individually", "colored", "as", "specified", "by", "colors" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/binary/VisualizeBinaryData.java#L149-L161
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/binary/VisualizeBinaryData.java
VisualizeBinaryData.renderBinary
public static BufferedImage renderBinary(GrayU8 binaryImage, boolean invert, BufferedImage out) { if( out == null || ( out.getWidth() != binaryImage.width || out.getHeight() != binaryImage.height) ) { out = new BufferedImage(binaryImage.getWidth(),binaryImage.getHeight(),BufferedImage.TYPE_BYTE_GRAY); } try { WritableRaster raster = out.getRaster(); DataBuffer buffer = raster.getDataBuffer(); if( buffer.getDataType() == DataBuffer.TYPE_BYTE ) { renderBinary(binaryImage, invert, (DataBufferByte)buffer, raster); } else if( buffer.getDataType() == DataBuffer.TYPE_INT ) { renderBinary(binaryImage, invert, (DataBufferInt)buffer, raster); } else { _renderBinary(binaryImage, invert, out); } } catch( SecurityException e ) { _renderBinary(binaryImage, invert, out); } // hack so that it knows the buffer has been modified out.setRGB(0,0,out.getRGB(0,0)); return out; }
java
public static BufferedImage renderBinary(GrayU8 binaryImage, boolean invert, BufferedImage out) { if( out == null || ( out.getWidth() != binaryImage.width || out.getHeight() != binaryImage.height) ) { out = new BufferedImage(binaryImage.getWidth(),binaryImage.getHeight(),BufferedImage.TYPE_BYTE_GRAY); } try { WritableRaster raster = out.getRaster(); DataBuffer buffer = raster.getDataBuffer(); if( buffer.getDataType() == DataBuffer.TYPE_BYTE ) { renderBinary(binaryImage, invert, (DataBufferByte)buffer, raster); } else if( buffer.getDataType() == DataBuffer.TYPE_INT ) { renderBinary(binaryImage, invert, (DataBufferInt)buffer, raster); } else { _renderBinary(binaryImage, invert, out); } } catch( SecurityException e ) { _renderBinary(binaryImage, invert, out); } // hack so that it knows the buffer has been modified out.setRGB(0,0,out.getRGB(0,0)); return out; }
[ "public", "static", "BufferedImage", "renderBinary", "(", "GrayU8", "binaryImage", ",", "boolean", "invert", ",", "BufferedImage", "out", ")", "{", "if", "(", "out", "==", "null", "||", "(", "out", ".", "getWidth", "(", ")", "!=", "binaryImage", ".", "widt...
Renders a binary image. 0 = black and 1 = white. @param binaryImage (Input) Input binary image. @param invert (Input) if true it will invert the image on output @param out (Output) optional storage for output image @return Output rendered binary image
[ "Renders", "a", "binary", "image", ".", "0", "=", "black", "and", "1", "=", "white", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/binary/VisualizeBinaryData.java#L382-L404
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/h/HomographyInducedStereoLinePt.java
HomographyInducedStereoLinePt.process
public void process(PairLineNorm line, AssociatedPair point) { // t0 = (F*x) cross l' GeometryMath_F64.mult(F,point.p1,Fx); GeometryMath_F64.cross(Fx,line.getL2(),t0); // t1 = x' cross ((f*x) cross l') GeometryMath_F64.cross(point.p2, t0, t1); // t0 = x' cross e' GeometryMath_F64.cross(point.p2,e2,t0); double top = GeometryMath_F64.dot(t0,t1); double bottom = t0.normSq()*(line.l1.x*point.p1.x + line.l1.y*point.p1.y + line.l1.z); // e' * l^T GeometryMath_F64.outerProd(e2, line.l1, el); // cross(l')*F GeometryMath_F64.multCrossA(line.l2, F, lf); CommonOps_DDRM.add(lf,top/bottom,el,H); // pick a good scale and sign for H adjust.adjust(H, point); }
java
public void process(PairLineNorm line, AssociatedPair point) { // t0 = (F*x) cross l' GeometryMath_F64.mult(F,point.p1,Fx); GeometryMath_F64.cross(Fx,line.getL2(),t0); // t1 = x' cross ((f*x) cross l') GeometryMath_F64.cross(point.p2, t0, t1); // t0 = x' cross e' GeometryMath_F64.cross(point.p2,e2,t0); double top = GeometryMath_F64.dot(t0,t1); double bottom = t0.normSq()*(line.l1.x*point.p1.x + line.l1.y*point.p1.y + line.l1.z); // e' * l^T GeometryMath_F64.outerProd(e2, line.l1, el); // cross(l')*F GeometryMath_F64.multCrossA(line.l2, F, lf); CommonOps_DDRM.add(lf,top/bottom,el,H); // pick a good scale and sign for H adjust.adjust(H, point); }
[ "public", "void", "process", "(", "PairLineNorm", "line", ",", "AssociatedPair", "point", ")", "{", "// t0 = (F*x) cross l'", "GeometryMath_F64", ".", "mult", "(", "F", ",", "point", ".", "p1", ",", "Fx", ")", ";", "GeometryMath_F64", ".", "cross", "(", "Fx"...
Computes the homography based on a line and point on the plane @param line Line on the plane @param point Point on the plane
[ "Computes", "the", "homography", "based", "on", "a", "line", "and", "point", "on", "the", "plane" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/h/HomographyInducedStereoLinePt.java#L93-L115
train