Opencv camera cannot be opened alternative solution

Source: Internet
Author: User

Generally, you can use videocapture captrefrnc (0) to enable opencv.

 

After the system is reinstalled, to avoid installing a huge Visual Studio, we changed it to codeblocks. In addition, opencv was compiled using cmake + codeblocks, however, opencv compiled by default cannot enable the camera of the laptop. After trying other solutions, I thought about how to use k-lite codec pack and avisynth to write AVS scripts to solve the decoder. I used K-lite codec pack + AVS to open the camera.

 

If you also encounter the problem that opencv cannot open the camera and cannot solve it, try this solution.

 

Preparations:

1: Install the K-lite codec pack and select the full version to install it. In this way, you can obtain the graphstudionext

Http://www.codecguide.com/download_kl.htm

 

2: Install avisynth

Http://sourceforge.net/projects/avisynth2/files/AviSynth%202.5/

 

3: Install avisynth-as-DirectShow-capture.

Https://github.com/rdp-org/avisynth-as-directshow-capture

 

After the installation is complete, open graphstudionext

 

 

Enter the program, press Ctrl + F, or click graph-> Insert filter.

Find your camera. In general, there will be a cam keyword, my name is intergrated webcam, select it, and click Insert

Select your cam, and then use file-> Save As graph to save the. GRF file. For example, mine is E: \ cam. AVS.

The next step is to write an AVS script to open the GRF file.

Open notepad and enter directshowsource ("E: \ cam. GRF", audio = false, framecount = 1000000, FPS = 10)

Save as filename. AVS

Then, Use Media Player classic to open the file and test whether the file is successfully opened. If you can use Media Player classic to open the camera, the file is successfully opened.

 

After that, you only need to open the AVS file in opencv like opening a video file:

Videocapture captrefrnc ("E: \ cam. AVS ");

Opencv camera cannot be opened alternative solution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.