# I cannot create VideoCapture class instance in order to connect camera

**URL:** <https://forum.opencv.org/t/i-cannot-create-videocapture-class-instance-in-order-to-connect-camera/11464>\
**Category:** Android/Java\
**Tags:** videoio\
**Created:** [January 1, 2023, 6:07am UTC](https://forum.opencv.org/t/i-cannot-create-videocapture-class-instance-in-order-to-connect-camera/11464 "2023-01-01T06:07:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![STEEL](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/steel/32/6855_2.png) [@STEEL](https://forum.opencv.org/u/STEEL)\
**Post date:** [January 1, 2023, 6:07am UTC](https://forum.opencv.org/t/i-cannot-create-videocapture-class-instance-in-order-to-connect-camera/11464/1 "2023-01-01T06:07:03Z")

</div>

When I try to get image from my webcam, OpenCV throws an exception in following statement:  
new VideoCapture(0);  
It says “unknown exception” of type java.lang.Exception. I wonder how to fix this error.

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [January 1, 2023, 8:57am UTC](https://forum.opencv.org/t/i-cannot-create-videocapture-class-instance-in-order-to-connect-camera/11464/2 "2023-01-01T08:57:19Z")

</div>

and the _exact_ exception is ?

---

<div class="post-metadata">

**Author:** ![STEEL](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/steel/32/6855_2.png) [@STEEL](https://forum.opencv.org/u/STEEL)\
**Post date:** [January 1, 2023, 2:53pm UTC](https://forum.opencv.org/t/i-cannot-create-videocapture-class-instance-in-order-to-connect-camera/11464/3 "2023-01-01T14:53:04Z")

</div>

There is no other than root Exception class according to terminal in which the error message exists.

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [January 1, 2023, 3:40pm UTC](https://forum.opencv.org/t/i-cannot-create-videocapture-class-instance-in-order-to-connect-camera/11464/4 "2023-01-01T15:40:52Z")

</div>

opencv version ? hw ? how do you run this ?

do the [sample progs](https://github.com/opencv/opencv/blob/4.x/samples/android/color-blob-detection/src/org/opencv/samples/colorblobdetect/ColorBlobDetectionActivity.java) work ?

why are you trying to use the `VideoCapture` class directly ?

---

<div class="post-metadata">

**Author:** ![STEEL](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/steel/32/6855_2.png) [@STEEL](https://forum.opencv.org/u/STEEL)\
**Post date:** [January 1, 2023, 6:02pm UTC](https://forum.opencv.org/t/i-cannot-create-videocapture-class-instance-in-order-to-connect-camera/11464/5 "2023-01-01T18:02:24Z")

</div>

I have run as Windows application; not Android.
