Неизвестная ошибка использования камеры permission denied

Данный код отлично работает с камерой в версиях андроида ниже 6.0. Но с версией 6.0 выдаёт ошибку в использование камеры. Как можно исправить эту ошибку?

public class MainActivity extends AppCompatActivity {
private final String TAG = this.getClass().getName();

ImageView ivCamera, ivGallery, ivUpload, ivImage;

CameraPhoto cameraPhoto;
GalleryPhoto galleryPhoto;

final int CAMERA_REQUEST = 13323;
final int GALLERY_REQUEST = 22131;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    cameraPhoto = new CameraPhoto(getApplicationContext());
    galleryPhoto = new GalleryPhoto(getApplicationContext());

    ivImage = (ImageView)findViewById(R.id.ivImage);
    ivCamera = (ImageView)findViewById(R.id.ivCamera);
    ivGallery = (ImageView)findViewById(R.id.ivGallery);
    ivUpload = (ImageView)findViewById(R.id.ivUpload);

    ivCamera.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {



            try {
                startActivityForResult(cameraPhoto.takePhotoIntent(), CAMERA_REQUEST);
                cameraPhoto.addToGallery();

            } catch (IOException e) {
                e.printStackTrace();
                Toast.makeText(getApplicationContext(),
                        "Something Wrong while taking photos", Toast.LENGTH_SHORT).show();
            }
        }
    });

    ivGallery.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivityForResult(galleryPhoto.openGalleryIntent(), GALLERY_REQUEST);
        }
    });

}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if(resultCode == RESULT_OK){
        if(requestCode == CAMERA_REQUEST){
            String photoPath = cameraPhoto.getPhotoPath();
            try {
                Bitmap bitmap = ImageLoader.init().from(photoPath).requestSize(512, 512).getBitmap();
                ivImage.setImageBitmap(bitmap);
            } catch (FileNotFoundException e) {
                Toast.makeText(getApplicationContext(),
                        "Something Wrong while loading photos", Toast.LENGTH_SHORT).show();
            }

        }
        else if(requestCode == GALLERY_REQUEST){
            Uri uri = data.getData();

            galleryPhoto.setPhotoUri(uri);
            String photoPath = galleryPhoto.getPath();
            try {
                Bitmap bitmap = ImageLoader.init().from(photoPath).requestSize(512, 512).getBitmap();
                ivImage.setImageBitmap(bitmap);
            } catch (FileNotFoundException e) {
                Toast.makeText(getApplicationContext(),
                        "Something Wrong while choosing photos", Toast.LENGTH_SHORT).show();
            }
        }
    }
  }
 }

Android Manifest

Android Monitor

Main Activity

I have created WebView Activity and loading https://web.doar.zone/coronavirus

This URL required Camera permission which I had taken Runtime Permission in Android.

Here is the full code of MainActivity.java:

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "MainActivity";

    Context context;

    ActivityMainBinding binding;

    private String url = "https://web.doar.zone/coronavirus";

    @Override
    protected void onResume() {
        super.onResume();
        checkCameraPermission();
    }

    private void checkCameraPermission() {
        int writeExternalStorage = ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA);
        if (writeExternalStorage != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, 1001);
        }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        if (requestCode == 1001) {
            if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                //Do your stuff
                openWebView();
            } else {
                checkCameraPermission();
            }
        }
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
        context = getApplicationContext();

        openWebView();
    }

    @SuppressLint("SetJavaScriptEnabled")
    void openWebView() {

        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);

        final NetworkInfo networkInfo;
        if (connectivityManager != null) {
            networkInfo = connectivityManager.getActiveNetworkInfo();
            if (networkInfo != null && networkInfo.isConnectedOrConnecting()) {
                binding.internetTextView.setVisibility(View.INVISIBLE);
                binding.webView.setVisibility(View.VISIBLE);
                //binding.webView.getSettings().setUserAgentString("Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.3");
                binding.webView.getSettings().setJavaScriptEnabled(true);
                binding.webView.getSettings().setUseWideViewPort(true);
                binding.webView.getSettings().setDomStorageEnabled(true);
                binding.webView.setInitialScale(1);
                binding.webView.setWebChromeClient(new MyWebChromeClient());
                binding.webView.setWebViewClient(new WebViewClient() {

                    @Override
                    public boolean shouldOverrideUrlLoading(WebView webview, String url) {
                        Uri uri = Uri.parse(url);
                        if (uri.getScheme().contains("whatsapp") || uri.getScheme().contains("tel")) {
                            try {
                                Intent intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
                                if (intent.resolveActivity(getPackageManager()) != null)
                                    startActivity(intent);
                                return true;
                            } catch (URISyntaxException use) {
                                Log.e("TAG", use.getMessage());
                            }
                        } else {
                            webview.loadUrl(url);
                        }

                        return true;
                    }

                    @Override
                    public void onPageFinished(WebView view, String url) {
                        super.onPageFinished(view, url);
                    }
                });
                binding.webView.loadUrl(url);
            } else {

                binding.internetTextView.setVisibility(View.VISIBLE);
                binding.buttonTryAgain.setVisibility(View.VISIBLE);
                binding.webView.setVisibility(View.INVISIBLE);

                Toast.makeText(context, "Connect to Internet and Refresh Again", Toast.LENGTH_LONG).show();
            }
        } else {
            binding.internetTextView.setVisibility(View.VISIBLE);
            binding.buttonTryAgain.setVisibility(View.VISIBLE);
            binding.webView.setVisibility(View.INVISIBLE);

            Toast.makeText(context, "Connect to Internet and Refresh Again", Toast.LENGTH_LONG).show();
        }
    }


    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            if (keyCode == KeyEvent.KEYCODE_BACK) {
                if (binding.webView.canGoBack()) {
                    binding.webView.goBack();
                } else {
                    finish();
                }
                return true;
            }

        }
        return super.onKeyDown(keyCode, event);
    }

    class MyWebChromeClient extends WebChromeClient {

        MyWebChromeClient() {
            // TODO Auto-generated constructor stub
            binding.pb.setProgress(0);
        }

        @Override
        public void onPermissionRequest(final PermissionRequest request) {
            super.onPermissionRequest(request);
            //request.grant(request.getResources());
        }

        public void onProgressChanged(WebView view, int progress) {
            if (progress < 100  /* && pBar.getVisibility() == View.VISIBLE*/) {
                binding.pb.setVisibility(View.VISIBLE);
            }
            binding.pb.setProgress(progress);
            if (progress == 100) {
                binding.pb.setVisibility(View.GONE);
            }
        }
    }
}

Now I am getting error as below When I comment this line:

request.grant(request.getResources());

enter image description here

And If I uncomment this line then I am getting:

 java.lang.IllegalStateException: Either grant() or deny() has been already called.
    at org.chromium.android_webview.permission.AwPermissionRequest.c(PG:3)
    at org.chromium.android_webview.permission.AwPermissionRequest.b(PG:1)
    at Cn.grant(PG:8)
    at com.example.webviewapp.MainActivity$MyWebChromeClient.onPermissionRequest(MainActivity.java:164)
    at org.chromium.android_webview.AwContents.onPermissionRequest(PG:8)
    at android.os.MessageQueue.nativePollOnce(Native Method)
    at android.os.MessageQueue.next(MessageQueue.java:326)
    at android.os.Looper.loop(Looper.java:181)
    at android.app.ActivityThread.main(ActivityThread.java:7078)
2020-04-29 11:52:21.813 4943-4943/com.example.webviewapp W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)

Any Help?

I have created WebView Activity and loading https://web.doar.zone/coronavirus

This URL required Camera permission which I had taken Runtime Permission in Android.

Here is the full code of MainActivity.java:

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "MainActivity";

    Context context;

    ActivityMainBinding binding;

    private String url = "https://web.doar.zone/coronavirus";

    @Override
    protected void onResume() {
        super.onResume();
        checkCameraPermission();
    }

    private void checkCameraPermission() {
        int writeExternalStorage = ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA);
        if (writeExternalStorage != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, 1001);
        }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        if (requestCode == 1001) {
            if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                //Do your stuff
                openWebView();
            } else {
                checkCameraPermission();
            }
        }
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
        context = getApplicationContext();

        openWebView();
    }

    @SuppressLint("SetJavaScriptEnabled")
    void openWebView() {

        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);

        final NetworkInfo networkInfo;
        if (connectivityManager != null) {
            networkInfo = connectivityManager.getActiveNetworkInfo();
            if (networkInfo != null && networkInfo.isConnectedOrConnecting()) {
                binding.internetTextView.setVisibility(View.INVISIBLE);
                binding.webView.setVisibility(View.VISIBLE);
                //binding.webView.getSettings().setUserAgentString("Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.3");
                binding.webView.getSettings().setJavaScriptEnabled(true);
                binding.webView.getSettings().setUseWideViewPort(true);
                binding.webView.getSettings().setDomStorageEnabled(true);
                binding.webView.setInitialScale(1);
                binding.webView.setWebChromeClient(new MyWebChromeClient());
                binding.webView.setWebViewClient(new WebViewClient() {

                    @Override
                    public boolean shouldOverrideUrlLoading(WebView webview, String url) {
                        Uri uri = Uri.parse(url);
                        if (uri.getScheme().contains("whatsapp") || uri.getScheme().contains("tel")) {
                            try {
                                Intent intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
                                if (intent.resolveActivity(getPackageManager()) != null)
                                    startActivity(intent);
                                return true;
                            } catch (URISyntaxException use) {
                                Log.e("TAG", use.getMessage());
                            }
                        } else {
                            webview.loadUrl(url);
                        }

                        return true;
                    }

                    @Override
                    public void onPageFinished(WebView view, String url) {
                        super.onPageFinished(view, url);
                    }
                });
                binding.webView.loadUrl(url);
            } else {

                binding.internetTextView.setVisibility(View.VISIBLE);
                binding.buttonTryAgain.setVisibility(View.VISIBLE);
                binding.webView.setVisibility(View.INVISIBLE);

                Toast.makeText(context, "Connect to Internet and Refresh Again", Toast.LENGTH_LONG).show();
            }
        } else {
            binding.internetTextView.setVisibility(View.VISIBLE);
            binding.buttonTryAgain.setVisibility(View.VISIBLE);
            binding.webView.setVisibility(View.INVISIBLE);

            Toast.makeText(context, "Connect to Internet and Refresh Again", Toast.LENGTH_LONG).show();
        }
    }


    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            if (keyCode == KeyEvent.KEYCODE_BACK) {
                if (binding.webView.canGoBack()) {
                    binding.webView.goBack();
                } else {
                    finish();
                }
                return true;
            }

        }
        return super.onKeyDown(keyCode, event);
    }

    class MyWebChromeClient extends WebChromeClient {

        MyWebChromeClient() {
            // TODO Auto-generated constructor stub
            binding.pb.setProgress(0);
        }

        @Override
        public void onPermissionRequest(final PermissionRequest request) {
            super.onPermissionRequest(request);
            //request.grant(request.getResources());
        }

        public void onProgressChanged(WebView view, int progress) {
            if (progress < 100  /* && pBar.getVisibility() == View.VISIBLE*/) {
                binding.pb.setVisibility(View.VISIBLE);
            }
            binding.pb.setProgress(progress);
            if (progress == 100) {
                binding.pb.setVisibility(View.GONE);
            }
        }
    }
}

Now I am getting error as below When I comment this line:

request.grant(request.getResources());

enter image description here

And If I uncomment this line then I am getting:

 java.lang.IllegalStateException: Either grant() or deny() has been already called.
    at org.chromium.android_webview.permission.AwPermissionRequest.c(PG:3)
    at org.chromium.android_webview.permission.AwPermissionRequest.b(PG:1)
    at Cn.grant(PG:8)
    at com.example.webviewapp.MainActivity$MyWebChromeClient.onPermissionRequest(MainActivity.java:164)
    at org.chromium.android_webview.AwContents.onPermissionRequest(PG:8)
    at android.os.MessageQueue.nativePollOnce(Native Method)
    at android.os.MessageQueue.next(MessageQueue.java:326)
    at android.os.Looper.loop(Looper.java:181)
    at android.app.ActivityThread.main(ActivityThread.java:7078)
2020-04-29 11:52:21.813 4943-4943/com.example.webviewapp W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)

Any Help?

Contents

  • Setting up your camera
  • Troubleshooting and errors
  • Browser-specific camera help
  • More camera troubleshooting for Mac & PC

Setting up your camera

To set up your computer’s camera or webcam, please visit Device Setup on your Check-In page. For the best experience, we recommend using a Chrome browser.

Check in page highlighting Device Setup step to be completed

On the first page, you’ll be prompted to ‘Allow’ Kira Talent (app.kiratalent.com) to access your camera and microphone. Please click ‘Allow’ and ‘Remember’ in every prompt that appears.

In Chrome, Opera, and Edge — click ‘Allow’ in the prompt coming from the lock icon to the left of your address bar.

The device permissions prompt in Chrome, Opera, or Edge with "Allow" and "Block" options

In Firefox, click ‘Remember this decision’ and ‘Allow’ in the prompt coming from the camera icon to the left of your address bar.

The device permissions prompt in Firefox with "Allow" and "Don't Allow" options

Once you’ve successfully allowed Kira to access your camera and microphone, you should be able to see yourself on the screen.

Please see our Microphone Setup & Troubleshooting article for information about setting up your microphone.


Troubleshooting & errors

Having issues with your camera? Please see the tips below.

‘We don’t have access to your camera or microphone’

Click «Show more’, and refer to the specific error below.

Error stating "we don't have access to your camera or microphone"

NotAllowedError: Permission denied

Error showing 'NotAllowed' under the 'Show more' button

This error message occurs when the Kira platform has been denied access to your camera or microphone, either for your current browsing session or globally across your computer.

In Chrome, Opera, and Edge, ensure your camera and microphone options under the lock icon are changed to ‘Allow’ instead of ‘Block’. Refresh the page, or start a new browser session.

Menu in Chrome, Opera, and Edge where device permissions are changed from Block to Allow

In Firefox, click the small x’s beside ‘Blocked Temporarily’ for your camera and microphone. Refresh the page, or start a new browser session.

Menu in Firefox where a 'Blocked Temporarily' permission can be removed

If this didn’t work, please double-check your camera and microphone settings in your browser. Ensure that the ‘Ask before accessing’ option is turned on, and that the Kira Talent site is not under the blocked list. 

Chrome settings where blocked sites can be removed, and choices about allowing access to camera and microphones can be made

NotFoundError: Requested device not found

Error showing 'NotFound' under the 'Show more' button

If you’re seeing this error, your camera and/or microphone cannot be found by your browser. This could mean they aren’t working properly, they’re being used somewhere else, or they don’t exist. If you don’t have a camera or microphone, please review the device requirements for Kira. 

If your camera and microphone work with other sites, ensure all other applications and browsers that could be using them are closed. If the issue persists, please try again using incognito Chrome.

NotReadableError: Concurrent mic process limit

Error showing 'NotReadable' under the 'Show more' button

This error message typically indicates an issue with multiple camera and/or microphone options in Firefox. If this error persists for you, we recommend simply trying another browser.

OvercontrainedError

This error typically means that your camera and/or microphone is being used in too many places at once. Please close everything down, and try to complete a Device Setup again in an incognito Chrome browser.

‘We can’t detect your camera or microphone’

Error stating "we can't detect your camera or microphone"

This error message indicates that the Kira platform cannot detect or use your camera and/or microphone. To double-check you have the equipment required to complete Kira, please refer to our Supported Browsers & Devices article. If the issue persists, please try again using incognito Chrome.

‘Something went wrong while accessing your camera and microphone.’

Error stating "something went wrong while accessing your camera or microphone"

This error message could indicate that there are detectable hardware issues coming from your operating system, browser, or webpage. If the issue persists, this may be a browser-specific or computer-specific issue, or you could have third party extensions that are blocking the Kira platform from accessing our camera or microphone. To double-check you have the equipment required to complete Kira, please refer to our Supported Browsers & Devices article. If the issue persists, please try again using incognito Chrome.

‘Please ensure your camera is connected and access is allowed’

If you’re receiving this error in a live Kira interview, the platform doesn’t have access to your camera.

First, make sure your camera is working in other applications. Then, close your browser, re-open your unique link, and allow the Kira platform access to your camera again.

If that doesn’t work, try selecting another option from the dropdown, using a new browser, or restarting your computer. We also recommend going through another Device Setup on your Check-In page.


Browser-specific help

  • Chrome
  • Firefox
  • Edge
  • Opera

If you’re not using any of the browsers above, please refer to our Supported Browsers article.


Camera troubleshooting tips for Mac

  1. Make sure that all other programs that utilize the camera, such as Photo Booth and Facetime, are closed (including Zoom on another browser)
  2. Restart your computer, and start fresh with the «Setting up your camera» steps above.
  3. Check if the camera works in a Mac app, such as Photo Booth or Facetime, or an online webcam test.
  4. If your camera does not work in any application, contact Apple Support.
  5. If your camera works elsewhere and still not in Kira, please contact support@kiratalent.com.

Note: If you are on Mac OS 10.14 Mojave and are still having difficulty accessing the camera, check your operating system permissions to confirm that Kira has access to the camera. Visit your System Preferences, click Security & Privacy, click Camera, and ensure your specific browsers have been allowed to use your camera.

System preferences modal on a Mac
Security and Privacy page within System Preferences on a Mac


Camera troubleshooting tips for PC

  1. Make sure that all other programs that utilize the camera are not using the camera or are closed.
  2. Restart your computer, and start fresh with the «Setting up your camera» steps above.
  3. Test your camera with an external online webcam test.
  4. If your camera does not work in any application, visit your device’s support and downloads page to update the camera driver:
    • Logitech
    • Dell
    • Lenovo
    • HP
    • ASUS
    • Samsung
    • Sony (PC)
  5. If your camera works elsewhere and still not in Kira, please contact support@kiratalent.com.

Note: Windows 10 has a privacy feature that may block Kira from using the camera. Learn more about this feature and how to allow Kira access to your camera.

There are two types of permission.

Normal permission (does not need to ask from user)
Dangerous permissions (need to be asked)

В вашем манифесте есть 3 опасное разрешение.

<uses-permission android:name = "android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name = "android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name = "android.permission.CAMERA" />

См. нормальное и опасное разрешение в документации Android.

Вы должны ввести код для запроса разрешения.

Спроси разрешение

 ActivityCompat.requestPermissions(MainActivity.this,
                    new String[]{Manifest.permission.CAMERA},
                    1);

Обработайте результат

@Override
public void onRequestPermissionsResult(int requestCode,
                                       String permissions[], int[] grantResults) {
    switch (requestCode) {
        case 1: {

          // If request is cancelled, the result arrays are empty.
          if (grantResults.length > 0
                    && grantResults[0] == PackageManager.PERMISSION_GRANTED) {

                // permission was granted, yay! Do the
                // contacts-related task you need to do.          
            } else {

                // permission denied, boo! Disable the
                // functionality that depends on this permission.
                Toast.makeText(MainActivity.this, "Permission denied", Toast.LENGTH_SHORT).show();
            }
            return;
        }

        // other 'case' lines to check for other
        // permissions this app might request
    }
}

Кончик:

Если вы не хотите много писать для запроса разрешения в разных классах. Воспользуйтесь какой-нибудь библиотекой. Нравиться

  • https://github.com/tbruyelle/RxPermissions
  • https://github.com/Karumi/Dexter

Я использую RxPermissions. Которые обеспечивают простую функцию.

rxPermissions
    .request(Manifest.permission.CAMERA)
    .subscribe(granted -> {
        if (granted) { // Always true pre-M
           // I can control the camera now
        } else {
           // Oups permission denied
        }
    });

См. конфигурация для RxPermission

Более подробная информация: https://developer.android.com/training/permissions/requesting.html

  • Home
  • Forum
  • The Ubuntu Forum Community
  • Ubuntu Official Flavours Support
  • Hardware
  • [ubuntu] WEBCAM: «open /dev/video0: Permission denied»

  1. Arrow WEBCAM: «open /dev/video0: Permission denied»

    I’ve run into a problem while installing my webcam for use in amsn and skype etc.

    Part of the problem perhaps is that its one of the awkward Ricoh Motion-Eye webcams discussed in detail [here].
    Specifically a VGP-VCC2 in a Sony Vaio VGN-SZ3XWP.

    Code:

    user@host:~$ lsusb
    Bus 005 Device 003: ID 05ca:1830 Ricoh Co., Ltd Visual Communication Camera VGP-VCC2

    I suspect I’ve installed the driver correctly as I’ve created /dev/video0 and I can get the package ‘webcam’ to take a snapshot and save it via SSH on localhost. But aMSN, Cheese and Camorama won’t detect it. (I’ve installed it as described by epvipas in post #55, on kernel 2.6.27-11-generic).

    Strangely, webcam without admin rights returns…

    Code:

    user@host:~$ webcam
    reading config file: /home/user/.webcamrc
    v4l2: open /dev/video0: Permission denied
    v4l2: open /dev/video0: Permission denied
    v4l: open /dev/video0: Permission denied
    no grabber device available

    However, with root access works fine…

    Code:

    user@host:~$ sudo webcam
    reading config file: /home/user/.webcamrc
    video4linux webcam v1.5 - (c) 1998-2002 Gerd Knorr
    grabber config:
      size 320x240 [none]
      input (null), norm (null), jpeg quality 75
      rotate=0, top=0, left=5, bottom=240, right=320
    ssh config [ftp]:
      user@localhost:/home/user/cam
      uploading.jpeg => webcam2.jpeg

    Stanger still, aMSN, Cheese and Camorama still won’t conect to the webcam when run as root.

    eg. sudo camorama
    Error Dialog: Error (camorama)
    Msg: Could not connect to the video device (/dev/video0). Please check the connection.

    Has anyone experience of this of can offer a solution?
    Thanks.

    Last edited by switchseven; February 3rd, 2009 at 04:24 AM.


  2. Re: WEBCAM: «open /dev/video0: Permission denied»

    Hello,

    I solved the problem. You must give to the user (you) permission for use video devices. Go to System > Administration > Users and Groups. Unlock and select your username. In user privileges, you must enable the line «Capture video from TV or webcams, and use 3d acceleration«, log off and log in.

    I hope that help you. Greetings,

    Pablo.


  3. Re: WEBCAM: «open /dev/video0: Permission denied»

    after days of pulling my hair out your solution made my skype work…thanks very much.


  4. Re: WEBCAM: «open /dev/video0: Permission denied»

    Quote Originally Posted by pnavarrc
    View Post

    Hello,

    I solved the problem. You must give to the user (you) permission for use video devices. Go to System > Administration > Users and Groups. Unlock and select your username. In user privileges, you must enable the line «Capture video from TV or webcams, and use 3d acceleration«, log off and log in.

    I hope that help you. Greetings,

    Pablo.

    How do i do this from the command line?

    Thanks Markp1989?

    Desktop:i7 875k|4gb OCZ platinum ddr3 2000|Evga P55 LE mobo|OCZ RevoDrive 50gb|ATI 5850 Black Edition|Silverstone FT02|corsair tx650
    Portable: 13″ Macbook Pro 2.8ghz i7 16gb RAM | Asus EEE TF101 | Samsung Galaxy S2


  5. Re: WEBCAM: «open /dev/video0: Permission denied»

    Use usermod to ad the group video
    man usermod

    Code:

    sudo usermod -a -G group user

    After that logout and back in and it will work.


  6. Re: WEBCAM: «open /dev/video0: Permission denied»

    It doesn’t work for me!! I have

    $ ls -l /dev/video0
    crw-rw-rw-+ 1 root video 81, 0 2009-11-25 13:45 /dev/video0
    $ grep video /etc/group
    video:44:dori,marci,apu
    $ whoami
    apu

    $ xawtv -c /dev/video0
    This is xawtv-3.95.dfsg.1, running on Linux/x86_64 (2.6.31-15-generic)
    xinerama 0: 1680×1050+0+0
    WARNING: No DGA direct video mode for this display.
    /dev/video0 [v4l2]: no overlay support
    v4l-conf had some trouble, trying to continue anyway
    v4l2: open /dev/video0: Enged�ly megtagadva
    v4l2: open /dev/video0: Enged�ly megtagadva
    v4l: open /dev/video0: Enged�ly megtagadva
    no video grabber device available

    (Enged�ly megtagadva = Permission denied)


Bookmarks

Bookmarks


Posting Permissions

Я хотел бы использовать веб-камеру моего старого ноутбука (мой ноутбук — Packard Bell EasyNote MX37), чтобы делать потоковое видео.

Я пытаюсь сделать это потоковое видео через VLC, следуя этому руководству от Ubuntu 14.04 LTS.

К сожалению, я застреваю, когда я применяю эту командную строку:

cvlc v4l2:///dev/video0 :v4l2-standard= :input-slave=alsa://hw:0,0
:live-caching=300
:sout="#transcode{vcodec=WMV2,vb=800,acodec=wma2,ab=128,channels=2,samplerate=44100}:http{dst=:8080/stream.wmv}"

В самом деле, я получаю это сообщение об ошибке:

VLC media player 2.1.6 Rincewind (revision 2.1.6-0-gea01d28)
[0x19....] dummy interface: using the dummy interface module...
[0x7f1................] main access out error: socket bind error (Permission denied)
[0x7f1................] main access out error: socket bind error (Permission denied)
[0x7f1................] main access out error: cannot create socket(s) for HTTP host
[0x7f1................] access_output_http access out error: cannot start HTTP server
[0x7f1................] stream_out_standard stream out error: no suitable sout access module for 'http/asf://:8080/stream.wmv'
[0x7f1................] main stream output error: stream chain failed for 'transcode{vcodec=WMV2,vb=800,acodec=wma2,ab=128,channels=2,samplerate=44100}:http{dst=:8080/stream.wmv}'
[0x7f1................] main input error: cannot start stream output instance, aborting

Большое спасибо за вашу помощь!

PS: Цель состоит в том, чтобы следить за моей парковкой.

I want to get and storage a photo from an android camera. This is the code:

public void avviaFotocamera(View v){
        this.launchCamera();
    }

    private void launchCamera() {
        try {
            mOutputFile = new File(getExternalStorageDirectory(),  "temp.jpg");
            Intent intentCamera = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            intentCamera.putExtra(MediaStore.EXTRA_OUTPUT,
                    Uri.fromFile(mOutputFile));
            startActivityForResult(intentCamera, CAMERA_REQUEST);
        }   catch (Exception e) {
            Toast t = Toast.makeText(this, "Si è verificato un errore durante l'acquisizione dell'immagine:\n" + e.toString(), Toast.LENGTH_LONG);
            t.show();
        }
    }

        @Override
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {

            if(requestCode == CAMERA_REQUEST) {
                try {
                    Bitmap datiFoto = android.provider.MediaStore.Images.Media.getBitmap(this.getContentResolver(),
                                      Uri.fromFile(mOutputFile));
                    saveBitmap(datiFoto);
                    mOutputFile.delete();
                }   catch (Exception e) {
                    Toast t = Toast.makeText(this, "Si è verificato un errore durante l'acquisizione dell'immagine:\n" + e.toString(), Toast.LENGTH_LONG);
                    t.show();
                }
            }
        }

    private void saveBitmap(Bitmap datiFoto) {
        try {
            //Nome del file da assegnare all'immagine
            final String fileName = "prova.jpg";
            FileOutputStream out = new FileOutputStream(getExternalStorageDirectory ()+fileName);
            datiFoto.compress(Bitmap.CompressFormat.JPEG, 90, out);
        }   catch (Exception e) {
            Toast t = Toast.makeText(this, "Si è verificato un errore durante il salvataggio dell'immagine:\n" + e.toString(), Toast.LENGTH_LONG);
            t.show();
            e.printStackTrace();
        }
    }

however i get this error: java.io.FileNotFoundException: /prova.jpg: open failed: EACCES (Permission denied).
This is the manifest where i add all the required permissions:

 <uses-sdk
        android:maxSdkVersion="22"
        android:minSdkVersion="15"
        android:targetSdkVersion="15" />

    <uses-permission
        android:name="android.permission.WRITE_EXTERNAL_STORAGE"
        android:maxSdkVersion="22" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission
        android:name="android.permission.READ_EXTERNAL_STORAGE"
        android:maxSdkVersion="22" />
    <uses-permission android:name="android.permission.SET_DEBUG_APP" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_CONTACTS"/>
    <uses-feature android:name="android.hardware.camera"/>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="com.javapapers.android.maps.path.permission.MAPS_RECEIVE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />  

How can i fix it??

Данный код отлично работает с камерой в версиях андроида ниже 6.0. Но с версией 6.0 выдаёт ошибку в использование камеры. Как можно исправить эту ошибку?

public class MainActivity extends AppCompatActivity {
private final String TAG = this.getClass().getName();

ImageView ivCamera, ivGallery, ivUpload, ivImage;

CameraPhoto cameraPhoto;
GalleryPhoto galleryPhoto;

final int CAMERA_REQUEST = 13323;
final int GALLERY_REQUEST = 22131;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    cameraPhoto = new CameraPhoto(getApplicationContext());
    galleryPhoto = new GalleryPhoto(getApplicationContext());

    ivImage = (ImageView)findViewById(R.id.ivImage);
    ivCamera = (ImageView)findViewById(R.id.ivCamera);
    ivGallery = (ImageView)findViewById(R.id.ivGallery);
    ivUpload = (ImageView)findViewById(R.id.ivUpload);

    ivCamera.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {



            try {
                startActivityForResult(cameraPhoto.takePhotoIntent(), CAMERA_REQUEST);
                cameraPhoto.addToGallery();

            } catch (IOException e) {
                e.printStackTrace();
                Toast.makeText(getApplicationContext(),
                        "Something Wrong while taking photos", Toast.LENGTH_SHORT).show();
            }
        }
    });

    ivGallery.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivityForResult(galleryPhoto.openGalleryIntent(), GALLERY_REQUEST);
        }
    });

}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if(resultCode == RESULT_OK){
        if(requestCode == CAMERA_REQUEST){
            String photoPath = cameraPhoto.getPhotoPath();
            try {
                Bitmap bitmap = ImageLoader.init().from(photoPath).requestSize(512, 512).getBitmap();
                ivImage.setImageBitmap(bitmap);
            } catch (FileNotFoundException e) {
                Toast.makeText(getApplicationContext(),
                        "Something Wrong while loading photos", Toast.LENGTH_SHORT).show();
            }

        }
        else if(requestCode == GALLERY_REQUEST){
            Uri uri = data.getData();

            galleryPhoto.setPhotoUri(uri);
            String photoPath = galleryPhoto.getPath();
            try {
                Bitmap bitmap = ImageLoader.init().from(photoPath).requestSize(512, 512).getBitmap();
                ivImage.setImageBitmap(bitmap);
            } catch (FileNotFoundException e) {
                Toast.makeText(getApplicationContext(),
                        "Something Wrong while choosing photos", Toast.LENGTH_SHORT).show();
            }
        }
    }
  }
 }

Android Manifest

Android Monitor

Main Activity

SVE's user avatar

SVE

22.3k10 золотых знаков56 серебряных знаков118 бронзовых знаков

задан 4 мая 2016 в 16:00

Kim Vladislav's user avatar

Permission denied...

Это не спроста. Начиная с Android 6.0 и выше нужно обрабатывать такие permission, спрашивая у пользователя давать добро на использование камеры или нет.

private static final int PERMISSION_REQUEST = 1;

if(ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED){
                ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, PERMISSION_REQUEST);//выводит диалог, где пользователю предоставляется выбор
        }else{
             //продолжаем работу или вызываем метод или класс
        }

Обновление ответа:

public class MainActivity extends AppCompatActivity {
private static final int PERMISSION_REQUEST = 1;
 ....


ivCamera.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
  if(ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED){
                    ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, PERMISSION_REQUEST);//выводит диалог, где пользователю предоставляется выбор
            }else{
                try {
                startActivityForResult(cameraPhoto.takePhotoIntent(), CAMERA_REQUEST);
                cameraPhoto.addToGallery();

            } catch (IOException e) {
                e.printStackTrace();
                Toast.makeText(getApplicationContext(),
                        "Something Wrong while taking photos", Toast.LENGTH_SHORT).show();
            }
            }  
        }
    });

ответ дан 4 мая 2016 в 16:41

iFr0z's user avatar

iFr0ziFr0z

5,0022 золотых знака17 серебряных знаков40 бронзовых знаков

4

Error Permission Denied

What a host or guest should do when they get the error message ‘Permission denied’ or ‘Permission denied by system’.

Before recording, a host or guest might get an error message that reads ‘Notallowederror: Permission denied’ or ‘Notallowederror: Permission denied by system’.

In this article:

Issue

When a host or guest is on a recording page, they get an error message that says ‘Notallowederror: Permission denied’ or ‘Notallowederror: Permission denied by system’.

Causes

Zencastr needs access to participants’ microphones for all recording modes and also needs access to participants’ cameras for the ‘Record Audio Only, Show Video’ and ‘Record Audio and Video’ modes.

‘Permission denied by system’ is an error that appears when Zencastr is not able to access a participant’s microphone and/or camera. The participant (host or guest) who sees the error on their screen is the person whose microphone or camera is not being accessed.

This most frequently happens when:

Less frequently, this might happen when:

Troubleshooting

Try in this order:

1. Enable microphone (and camera*) access in the browser

2. Enable the browser to access microphone (and camera*) in the computer’s privacy settings

3. Check Zencastr settings

For Host

Note: To change a device, click on the dropdown bar for the audio input, audio output, and/or camera and select the new device.

For Guest

Note: To change a device, the guest clicks on the dropdown bar and selects the new device.

4. Close any programs besides Zencastr that are using the camera*

5. Test the microphone (and camera*)

6. Contact Zencastr Support

If none of the above steps work, contact Zencastr Support via chat or email.


Related Articles

Error Accessing Microphone or Webcam

Error Getting The User’s Local Stream

I Can’t Hear My Guest

Guest Green Room

Selecting Cameras

Contents

  • Setting up your camera
  • Troubleshooting and errors
  • Browser-specific camera help
  • More camera troubleshooting for Mac & PC

Setting up your camera

To set up your computer’s camera or webcam, please visit Device Setup on your Check-In page. For the best experience, we recommend using a Chrome browser.

Check in page highlighting Device Setup step to be completed

On the first page, you’ll be prompted to ‘Allow’ Kira Talent (app.kiratalent.com) to access your camera and microphone. Please click ‘Allow’ and ‘Remember’ in every prompt that appears.

In Chrome, Opera, and Edge — click ‘Allow’ in the prompt coming from the lock icon to the left of your address bar.

The device permissions prompt in Chrome, Opera, or Edge with "Allow" and "Block" options

In Firefox, click ‘Remember this decision’ and ‘Allow’ in the prompt coming from the camera icon to the left of your address bar.

The device permissions prompt in Firefox with "Allow" and "Don't Allow" options

Once you’ve successfully allowed Kira to access your camera and microphone, you should be able to see yourself on the screen.

Please see our Microphone Setup & Troubleshooting article for information about setting up your microphone.


Troubleshooting & errors

Having issues with your camera? Please see the tips below.

‘We don’t have access to your camera or microphone’

Click «Show more’, and refer to the specific error below.

Error stating "we don't have access to your camera or microphone"

NotAllowedError: Permission denied

Error showing 'NotAllowed' under the 'Show more' button

This error message occurs when the Kira platform has been denied access to your camera or microphone, either for your current browsing session or globally across your computer.

In Chrome, Opera, and Edge, ensure your camera and microphone options under the lock icon are changed to ‘Allow’ instead of ‘Block’. Refresh the page, or start a new browser session.

Menu in Chrome, Opera, and Edge where device permissions are changed from Block to Allow

In Firefox, click the small x’s beside ‘Blocked Temporarily’ for your camera and microphone. Refresh the page, or start a new browser session.

Menu in Firefox where a 'Blocked Temporarily' permission can be removed

If this didn’t work, please double-check your camera and microphone settings in your browser. Ensure that the ‘Ask before accessing’ option is turned on, and that the Kira Talent site is not under the blocked list. 

Chrome settings where blocked sites can be removed, and choices about allowing access to camera and microphones can be made

NotFoundError: Requested device not found

Error showing 'NotFound' under the 'Show more' button

If you’re seeing this error, your camera and/or microphone cannot be found by your browser. This could mean they aren’t working properly, they’re being used somewhere else, or they don’t exist. If you don’t have a camera or microphone, please review the device requirements for Kira. 

If your camera and microphone work with other sites, ensure all other applications and browsers that could be using them are closed. If the issue persists, please try again using incognito Chrome.

NotReadableError: Concurrent mic process limit

Error showing 'NotReadable' under the 'Show more' button

This error message typically indicates an issue with multiple camera and/or microphone options in Firefox. If this error persists for you, we recommend simply trying another browser.

OvercontrainedError

This error typically means that your camera and/or microphone is being used in too many places at once. Please close everything down, and try to complete a Device Setup again in an incognito Chrome browser.

‘We can’t detect your camera or microphone’

Error stating "we can't detect your camera or microphone"

This error message indicates that the Kira platform cannot detect or use your camera and/or microphone. To double-check you have the equipment required to complete Kira, please refer to our Supported Browsers & Devices article. If the issue persists, please try again using incognito Chrome.

‘Something went wrong while accessing your camera and microphone.’

Error stating "something went wrong while accessing your camera or microphone"

This error message could indicate that there are detectable hardware issues coming from your operating system, browser, or webpage. If the issue persists, this may be a browser-specific or computer-specific issue, or you could have third party extensions that are blocking the Kira platform from accessing our camera or microphone. To double-check you have the equipment required to complete Kira, please refer to our Supported Browsers & Devices article. If the issue persists, please try again using incognito Chrome.

‘Please ensure your camera is connected and access is allowed’

If you’re receiving this error in a live Kira interview, the platform doesn’t have access to your camera.

First, make sure your camera is working in other applications. Then, close your browser, re-open your unique link, and allow the Kira platform access to your camera again.

If that doesn’t work, try selecting another option from the dropdown, using a new browser, or restarting your computer. We also recommend going through another Device Setup on your Check-In page.


Browser-specific help

  • Chrome
  • Firefox
  • Edge
  • Opera

If you’re not using any of the browsers above, please refer to our Supported Browsers article.


Camera troubleshooting tips for Mac

  1. Make sure that all other programs that utilize the camera, such as Photo Booth and Facetime, are closed (including Zoom on another browser)
  2. Restart your computer, and start fresh with the «Setting up your camera» steps above.
  3. Check if the camera works in a Mac app, such as Photo Booth or Facetime, or an online webcam test.
  4. If your camera does not work in any application, contact Apple Support.
  5. If your camera works elsewhere and still not in Kira, please contact support@kiratalent.com.

Note: If you are on Mac OS 10.14 Mojave and are still having difficulty accessing the camera, check your operating system permissions to confirm that Kira has access to the camera. Visit your System Preferences, click Security & Privacy, click Camera, and ensure your specific browsers have been allowed to use your camera.

System preferences modal on a Mac
Security and Privacy page within System Preferences on a Mac


Camera troubleshooting tips for PC

  1. Make sure that all other programs that utilize the camera are not using the camera or are closed.
  2. Restart your computer, and start fresh with the «Setting up your camera» steps above.
  3. Test your camera with an external online webcam test.
  4. If your camera does not work in any application, visit your device’s support and downloads page to update the camera driver:
    • Logitech
    • Dell
    • Lenovo
    • HP
    • ASUS
    • Samsung
    • Sony (PC)
  5. If your camera works elsewhere and still not in Kira, please contact support@kiratalent.com.

Note: Windows 10 has a privacy feature that may block Kira from using the camera. Learn more about this feature and how to allow Kira access to your camera.

Понравилась статья? Поделить с друзьями:

Интересное по теме:

  • Неизвестная ошибка пикабу
  • Неизвестная ошибка инстаграм при попытке входа
  • Неизвестная ошибка окко на телевизоре
  • Неизвестная ошибка гугл аккаунта
  • Неизвестная ошибка не удалось декодировать см консоль браузера

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии