Home > OS >  Checking input in VideoCapture in Android Studio
Checking input in VideoCapture in Android Studio

Time:10-30

I have imported OpenCV into Android Studio and created an EditText option for the user to input their camera's streaming URL.

I want to use VideoCapture in OpenCV to get the video feed from the camera but first I want to check whether the inputted streaming URL is valid and give an appropriate output. Something along the lines of:

if (VideoCapture(input) == true)
{
    // toast camera detected
}
else
{
    // toast camera not detected
}

I am unsure of the exact syntax to do this and would highly appreciate some help.

CodePudding user response:

Use URLUtil to validate the URL as below.

 URLUtil.isValidUrl(url)

It will return True if URL is valid and false if URL is invalid.

if (URLUtil.isValidUrl(url))
{
    // toast camera detected
}
else
{
    // toast camera not detected
}
  • Related