How can I capture which direction is being panned using UIPanGestureRecognizer?

On UIPanGestureRecognizer you can use -velocityInView: to get the velocity of the fingers at the time that gesture was recognised. If you wanted to do one thing on a pan right and one thing on a pan left, for example, you could do something like: – (void)handleGesture:(UIPanGestureRecognizer *)gestureRecognizer { CGPoint velocity = [gestureRecognizer velocityInView:yourView]; if(velocity.x … Read more

Capturing image from webcam in java?

This JavaCV implementation works fine. Code: import org.bytedeco.javacv.*; import org.bytedeco.opencv.opencv_core.IplImage; import java.io.File; import static org.bytedeco.opencv.global.opencv_core.cvFlip; import static org.bytedeco.opencv.helper.opencv_imgcodecs.cvSaveImage; public class Test implements Runnable { final int INTERVAL = 100;///you may use interval CanvasFrame canvas = new CanvasFrame(“Web Cam”); public Test() { canvas.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE); } public void run() { new File(“images”).mkdir(); FrameGrabber grabber = new OpenCVFrameGrabber(0); // … Read more

Regex group capture in R with multiple capture-groups

str_match(), from the stringr package, will do this. It returns a character matrix with one column for each group in the match (and one for the whole match): > s = c(“(sometext :: 0.1231313213)”, “(moretext :: 0.111222)”) > str_match(s, “\\((.*?) :: (0\\.[0-9]+)\\)”) [,1] [,2] [,3] [1,] “(sometext :: 0.1231313213)” “sometext” “0.1231313213” [2,] “(moretext :: 0.111222)” … Read more

How to capture stdout output from a Python function call?

Try this context manager: from io import StringIO import sys class Capturing(list): def __enter__(self): self._stdout = sys.stdout sys.stdout = self._stringio = StringIO() return self def __exit__(self, *args): self.extend(self._stringio.getvalue().splitlines()) del self._stringio # free up some memory sys.stdout = self._stdout Usage: with Capturing() as output: do_something(my_object) output is now a list containing the lines printed by the … Read more

Capture Image from Camera and Display in Activity

Here’s an example activity that will launch the camera app and then retrieve the image and display it. package edu.gvsu.cis.masl.camerademo; import android.app.Activity; import android.content.Intent; import android.graphics.Bitmap; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.ImageView; public class MyCameraActivity extends Activity { private static final int CAMERA_REQUEST = 1888; private ImageView imageView; private static final int MY_CAMERA_PERMISSION_CODE … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)