"cv2.error: OpenCV(4.3.0) /io/opencv/modules/imgproc/src/drawing.cpp:2374: error: (-215:Assertion failed) p.checkVector(2, CV_32S) >= 0 in function 'fillPoly'" Code Answer's

You're definitely familiar with the best coding language Whatever that developers use to develop their projects and they get all their queries like "cv2.error: OpenCV(4.3.0) /io/opencv/modules/imgproc/src/drawing.cpp:2374: error: (-215:Assertion failed) p.checkVector(2, CV_32S) >= 0 in function 'fillPoly'" answered properly. Developers are finding an appropriate answer about cv2.error: OpenCV(4.3.0) /io/opencv/modules/imgproc/src/drawing.cpp:2374: error: (-215:Assertion failed) p.checkVector(2, CV_32S) >= 0 in function 'fillPoly' related to the Whatever coding language. By visiting this online portal developers get answers concerning Whatever codes question like cv2.error: OpenCV(4.3.0) /io/opencv/modules/imgproc/src/drawing.cpp:2374: error: (-215:Assertion failed) p.checkVector(2, CV_32S) >= 0 in function 'fillPoly'. Enter your desired code related query in the search bar and get every piece of information about Whatever code related question on cv2.error: OpenCV(4.3.0) /io/opencv/modules/imgproc/src/drawing.cpp:2374: error: (-215:Assertion failed) p.checkVector(2, CV_32S) >= 0 in function 'fillPoly'. 

cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'

By THINK989THINK989 on Jun 19, 2020
Hello Everyone,

I had run into the same problem a few days back. Here's my perspective on why this error came up and how can it be fixed.

The reason behind the error:-
- ```cv2.imread() or cv2.VideoCapture()``` can't find where the file is and hence gives src.empty() since None is returned instead of image or video
- If you are sure that the path specified is correct, then chances are the file being read is corrupted either completely or in a few bits and pieces.

If you got into this problem when working with an image then here is the fix:-
- Change the image, literally. If you don't want to change it then try ```from PIL import Image and Image.open()``` and see if that works and try to display the image by using matplotlib.
- Changing or reproducing the same image is the best option in my opinion.

If you got into this problem when working with a video then here is the fix:- 
- After using ```cv2.VideoCapture('video path')``` Try something like below example.
```
# suppose this was the source 
cap = cv2.VideoCapture('data/input.mpg')
# Get width and height of the frame of video
width  = cap.get(3) # float width
height = cap.get(4) # float height    
# Make a video writer to see if video being taken as input inflict any changes you make
fourcc = cv2.VideoWriter_fourcc(*"MJPG")
out_video = cv2.VideoWriter('result/output.avi', fourcc, 20.0, (int(width), int(height)), True)
# Then try this
while(cap.isOpened()):
        # Read each frame where ret is a return boollean value(True or False)
        ret, frame = cap.read()
        # if return is true continue because if it isn't then frame is of NoneType in that case you cant work on that frame
        if ret:
            # Any preprocessing you want to make on the frame goes here
            gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
            # See if preprocessing is working on the frame it should
            cv2.imshow('frame', gray)
            # finally write your preprocessed frame into your output video
            out_video.write(gray) # write the modifies frame into output video 
            # to forcefully stop the running loop and break out, if it doesnt work use ctlr+c
            if cv2.waitKey(1) & 0xFF == ord('q'):
                break
       # break out if frame has return NoneType this means that once script encounters such frame it breaks out 
       # You will get the error otherwise 
        else:
            break
# this will tell you from which frame the video is corrupted and need to be changed 
# this could be due to an empty frame. Empty frame might be a result of mistake made while creating or editing video in tools #like adobe premier pro or other products alike 
# You can check you output video it will contains all frame before the error is encountered
```
I hope this solves your problem and you can better debug your video next time you encounter something similar. 

Add Comment

5

cv2.error: OpenCV(4.3.0) /io/opencv/modules/imgproc/src/drawing.cpp:2374: error: (-215:Assertion failed) p.checkVector(2, CV_32S) >= 0 in function 'fillPoly'

By Innocent IbisInnocent Ibis on May 26, 2021
new_img = cv2.fillPoly(blank_img,[cnt],color =(255,255,255))

I was facing error in this line.

so The solution is make sure "cnt" must be int not float.

CHANGES:
cnt = np.array([[50,50], [50,150], [150,150], [150,50]],dtype=np.int32)

Add Comment

0

All those coders who are working on the Whatever based application and are stuck on cv2.error: OpenCV(4.3.0) /io/opencv/modules/imgproc/src/drawing.cpp:2374: error: (-215:Assertion failed) p.checkVector(2, CV_32S) >= 0 in function 'fillPoly' can get a collection of related answers to their query. Programmers need to enter their query on cv2.error: OpenCV(4.3.0) /io/opencv/modules/imgproc/src/drawing.cpp:2374: error: (-215:Assertion failed) p.checkVector(2, CV_32S) >= 0 in function 'fillPoly' related to Whatever code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about cv2.error: OpenCV(4.3.0) /io/opencv/modules/imgproc/src/drawing.cpp:2374: error: (-215:Assertion failed) p.checkVector(2, CV_32S) >= 0 in function 'fillPoly' for the programmers working on Whatever code while coding their module. Coders are also allowed to rectify already present answers of cv2.error: OpenCV(4.3.0) /io/opencv/modules/imgproc/src/drawing.cpp:2374: error: (-215:Assertion failed) p.checkVector(2, CV_32S) >= 0 in function 'fillPoly' while working on the Whatever language code. Developers can add up suggestions if they deem fit any other answer relating to "cv2.error: OpenCV(4.3.0) /io/opencv/modules/imgproc/src/drawing.cpp:2374: error: (-215:Assertion failed) p.checkVector(2, CV_32S) >= 0 in function 'fillPoly'". Visit this developer's friendly online web community, CodeProZone, and get your queries like cv2.error: OpenCV(4.3.0) /io/opencv/modules/imgproc/src/drawing.cpp:2374: error: (-215:Assertion failed) p.checkVector(2, CV_32S) >= 0 in function 'fillPoly' resolved professionally and stay updated to the latest Whatever updates. 

Whatever answers related to "cv2.error: OpenCV(4.3.0) /io/opencv/modules/imgproc/src/drawing.cpp:2374: error: (-215:Assertion failed) p.checkVector(2, CV_32S) >= 0 in function 'fillPoly'"

cv2.error: OpenCV(4.3.0) /io/opencv/modules/imgproc/src/drawing.cpp:2374: error: (-215:Assertion failed) p.checkVector(2, CV_32S) >= 0 in function 'fillPoly' cv2.error: OpenCV(4.3.0) /io/opencv/modules/imgproc/src/drawing.cpp:2374: error: (-215:Assertion failed) p.checkVector(2, CV_32S) >= 0 in function 'fillPoly' error: (-215:Assertion failed) !empty() in function 'cv::CascadeClassifier::detectMultiScale' error: (-215:Assertion failed) !empty() in function 'cv::CascadeClassifier::detectMultiScale' error: (-215:Assertion failed) !empty() in function 'cv::CascadeClassifier::detectMultiScale' error: (-215:Assertion failed) !empty() in function 'cv::CascadeClassifier::detectMultiScale' ERROR Error: ASSERTION ERROR: Stored value should never be NO_CHANGE. Error: Assertion failed: org-dartlang-sdk:///flutter_web_sdk/lib/_engine/engine/navigation/history.dart:284:14 _userProvidedRouteName != null is not true detector\nms\src/nms_cuda.cpp(9): error C3861: 'AT_CHECK': identifier not found alpha pose stream_socket_enable_crypto(): ssl operation failed with code 1 Message could not be sent. Mailer Error: SMTP Error: data not accepted.SMTP server error: DATA END command failed Detail: h8alkc4CZK9H0 Spam Rejected gnutls_handshake() failed: error in the pull function Whoops! Error: DOMException: Failed to execute 'addIceCandidate' on 'RTCPeerConnection': Error processing ICE candidate webpack Error can't resolve ./src stream_socket_enable_crypto(): ssl operation failed with code 1 tempcoderunnerfile.cpp:1:1: error: does not name a type error: *.cpp: Invalid argument error: failed to lookup view "layout" in views directory Failed to open file error: 2 cloud run error: container failed to start. failed to start and then listen on the port defined by the port environment variable. error failed to download metadata for repo 'appstream' ERROR: Failed building wheel for typed-ast error: request failed with status code 400 Failed assertion: 'constraints.hasBoundedWidth': is not true. error launcher chromeheadless failed 2 times (cannot start). giving up (node:621) UnhandledPromiseRejectionWarning: Error: Failed to launch chrome! failed: error during websocket handshake: unexpected response code: 400 carla X Error of failed request: BadDrawable (invalid Pixmap or Window parameter) OpenCV VideoCapture lag why video is not writing opencv
View All Whatever queries

Whatever queries related to "cv2.error: OpenCV(4.3.0) /io/opencv/modules/imgproc/src/drawing.cpp:2374: error: (-215:Assertion failed) p.checkVector(2, CV_32S) >= 0 in function 'fillPoly'"

cv2.error: OpenCV(4.3.0) /io/opencv/modules/imgproc/src/drawing.cpp:2374: error: (-215:Assertion failed) p.checkVector(2, CV_32S) >= 0 in function 'fillPoly' error: (-215:Assertion failed) !empty() in function 'cv::CascadeClassifier::detectMultiScale' difference between hard assertion and soft assertion Error: Assertion failed: org-dartlang-sdk:///flutter_web_sdk/lib/_engine/engine/navigation/history.dart:284:14 _userProvidedRouteName != null is not true ERROR Error: ASSERTION ERROR: Stored value should never be NO_CHANGE. Failed assertion: line 1861 pos 16: 'constraints.hasBoundedHeight': is not true. Failed assertion: 'constraints.hasBoundedWidth': is not true. cv2.cv2' has no attribute 'face_lbphfacerecognizer' print(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) print(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) ----> 1 import cv2 2 import os 3 import matplotlib.pyplot as plt 4 import numpy as np 5 import tensorflow as tf ModuleNotFoundError: No module named 'cv2' detector\nms\src/nms_cuda.cpp(9): error C3861: 'AT_CHECK': identifier not found alpha pose failed to solve with frontend dockerfile.v0: failed to read dockerfile: failed to create lease: write /var/lib/docker/buildkit/containerdmeta.db: read-only file system RuntimeError: size mismatch, m1: [1536 x 3], m2: [4096 x 101] at /opt/conda/conda-bld/pytorch_1587428398394/work/aten/src/TH/generic/THTensorMath.cpp:41 bresenham line drawing algorithm code Drawing a rectangle in Canvas with user input drawing default serializedproperty unity cloud run error: container failed to start. failed to start and then listen on the port defined by the port environment variable. assertion types what is soft assertion in selenium what is assertion in testng what is assertion in junit what is soft assertion Message could not be sent. Mailer Error: SMTP Error: data not accepted.SMTP server error: DATA END command failed Detail: h8alkc4CZK9H0 Spam Rejected Failed to refresh tokens. Failed to get credentials. Failed to refresh tokens. Failed to get credentials amplify RemoteConnection failed to initialize: RemoteConnection failed to open pipe Execution failed for task ':app:processDebugResources'. > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade > Android resource linking failed gnutls_handshake() failed: error in the pull function webpack Error can't resolve ./src Whoops! Error: DOMException: Failed to execute 'addIceCandidate' on 'RTCPeerConnection': Error processing ICE candidate remove modules npx rpm modules private repo terraform modules azure terraform aws modules s3 bpy: couldn't find 'scripts/modules', blender probably wont start. error: *.cpp: Invalid argument tempcoderunnerfile.cpp:1:1: error: does not name a type convert numpy array to cv2 image cv2.cvtcolor grayscale set destination of image in cv2.imwrite cv2.imread cannot find reference for picture import cv2 illegal instruction (core dumped) jetson nano change src with inpute type="file" npx eslint src image src tag is not working in webview android Description Resource Path Location Type Content is not allowed in trailing section. hibernate.cfg.xml /ProjectwithMaven/src/main/java/com/tut line 15 Language Servers yii2 img src error: failed to lookup view "layout" in views directory error: RPC failed; curl 18 transfer closed with outstanding read data remaining fatal: the remote end hung up unexpectedly (node:621) UnhandledPromiseRejectionWarning: Error: Failed to launch chrome! error: request failed with status code 400 --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-nmT4k7/psycopg2/ failed: error during websocket handshake: unexpected response code: 400 carla X Error of failed request: BadDrawable (invalid Pixmap or Window parameter) open request has failed with SFTP error Permission Denied permission denied error failed to download metadata for repo 'appstream' Failed to open file error: 2 error = Converting object to an encodable object failed: Instance of 'SendCart' error launcher chromeheadless failed 2 times (cannot start). giving up ERROR: Failed building wheel for typed-ast "ctx":"initandlisten","msg":"Failed to unlink socket file","attr":{"path":"/tmp/mongodb-27017.sock","error":"Operation not permitted"}} vboxnetadpctl: error while adding new interface: failed to open /dev/vboxnetctl: no such file or directory. ERROR: Service 'webapp' failed to build : When using COPY with more than one source file, the destination must be a directory and end with a / how to use flush in cpp https://www.programiz.com/cpp-programming/examples/add-numbers dwonload groupconcat.cpp opencv pencil sketch effect draw circle opencv opencv for video recording Display an image over another image at a particular co-ordinates in openCV capturing-video-from-two-cameras-in-opencv-at-once OpenCV VideoCapture lag how to input a picture into opencv raspberry pi perform zero crossing using openCV identify color sequence with OpenCV why video is not writing opencv opencv and reolink camera how to crop the image using opencv opencv videocapture rtmp changing parent function states in child function which keyword is used to transfer control from a function back to the calling function in c Run a function called hello before you declare it. The function should simply print out "hello" Write a function definition of occurrences(text1, text2) that takes two string arguments. The function returns the number of times a character from the first argument occurs in the second argument. Expected a state variable declaration. If you intended this as a fallback function or a function to handle plain ether transactions, use the "fallback" keyword or the "receive" keyword instead. similar function like lazy function in pandera SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation http 000 connection failed Execution failed for task ':app:processDebugGoogleServices'. Failed to load config "airbnb" to extend from. Referenced from: how to take failed screenshot in selenium rabbit mq management failed to create cookie file requirements check failed for jdk 8 ( failed to load resource: net::ER_BLOCKED_BY_CLIENT hotjar failed to open stream: No such file or directory in artisan on line 18 flutter failed to load asset image could not be opened in append mode failed to open stream permission denied Failed to set time: Automatic time synchronization is enabled COPY failed: file not found in build context or excluded by .dockerignore: stat package.json: file does not exist mongoimport Failed: invalid JSON input. Position: 74. Character: I Failed to determine a suitable driver class mongodb Warning: Failed child context type: Invalid child context `virtualizedCell.cellKey` of type `number` supplied to `CellRenderer`, expected `string`. Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified and no embedded datasource could be auto-configured. ALTER DATABASE failed because a lock could not be placed on database Task :expo-updates:checkDebugManifest FAILED Failed to unlink socket file amazon mongodb command failed with EACCES android password authentication failed for user postgres pgadmin Execution failed for task ':app:processDebugGoogleServices'. > No matching client found for package failed to execute run failed test cases in jenkins elasticsearchexception[failed to bind service]; nested: accessdeniedexception WebSocket connection to 'wss://s-euw1b-nss-201.europe-west1.firebasedatabase.app/.ws?v=5&s=WKO6LXOUdJD93R9BqJdhZPJaZb2itgms&ns=oshop-dc8f0-default-rtdb' failed: failed to build h5py FATAL: password authentication failed for user how do you run failed tests gradle build failed failed to set the zipline ImportError: DLL load failed: The specified module could not be found. netmgr : Failed to open QEMU pipe 'qemud:network': Invalid argument reason: failed to load driver class com.mysql.cj.jdbc.driver in either of hikariconfig class loader or thread context classloader create react app failed with code 1 ssh monitoring failed ssh logins unlink of file failed git pull you failed to push some refs to git Because flutter_app_ui_kit depends on flutter_localizations any which doesn't exist (could not find package flutter_localizations at https://pub.dartlang.org), version solving failed. win32api dll load failed kernel Uncaught (in promise) TypeError: Failed to execute 'put' on 'Cache': Request scheme 'chrome-extension' is unsupported invalidcharactererror: failed to execute Warning: require(/home/../wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php): failed to open stream: Failed to resolve loader: worker-loader Vagrant RawFile failed to create the raw output file rerun failed test in testng screenshot for failed test ImportError: DLL load failed while importing _sqlite3: The specified module could not be found. java stack verification failed marlin pid autotune failed timeout JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510) COPY failed: no source files were specified ActiveResource::UnauthorizedAccess: Failed. Response code = 401. Response message = Unauthorized ([API] Invalid API key or access token (unrecognized login or wrong password)) android resource linking failed flutter why to rerun failed test cases : keyserver receive failed: No dirmngr why testing failed test ModelViewer failed to load: net::ERR_CLEARTEXT_NOT_PERMITTED (WebResourceErrorType.unknown -1) failed to run perl qt why testing failed test cases how to solve CopyBuffer from HiLo failed, no data python pip Failed to build cryptography The "CreateAppHost" task failed unexpectedly. WSL2 request to https://registry.npmjs.org/yarn failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org how to take screenshot in failed test scenarios E: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/main/binary-arm64/Packages 404 Not Found [IP: 91.189.88.152 80] adb: sideload connection failed: recovery mode android 2020-11-12 20:16:12.200 16641-16641/eniso.IA22.tp1X E/ActivityThread: Failed to find provider info for com.huawei.hiaction.provider.HiActionManagerProvider failed to load resource the server responded with a status of 400 () conversion failed when converting date and/or time from character string. RuntimeError: Failed to process string with tex because latex could not be found The "RazorTagHelper" task failed unexpectedly. Network initialization failed how to rerun failed test in testng how to run failed test cases in cucumber Failed to find .env file at default condahttperror: http 000 connection failed for url testng rerun failed tests Failed to apply plugin [class 'com.google.gms.googleservices.GoogleServicesPlugin'] site:stackoverflow.com authorization failed or requested resource not found in oracle cloud ntp service keeping failed with result 'exit-code' failed to initialize plugin et_quicktags wordpress Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0 stream_socket_enable_crypto(): ssl operation failed with code 1 server tomcat v9 0 server at localhost failed to start Syntax Error: TypeError: getProcessedPlugins is not a function PHP Fatal error: Call to undefined function factory() in Psy Shell code on line 1, LARAVEL 8 Issue solved Using 'parse(String): MediaType?' is an error. moved to extension function This line is compulsory to add anytime you want to use the Pygame library. It must be added before any other pygame function, else an initialization error may occur. function undefined error in internet explorer error: error:0909006c:pem routines:get_name:no start line Fatal error: Uncaught GuzzleHttp\Exception\RequestException: cURL error 60: SSL certificate problem: unable to get local issuer certificate Assets\scrips\control.cs(21,61): error CS1003: Syntax error, ',' expected Facebook wordpress Login Error: There is an error in logging you into this application. Please try again later. company-list.component.html:251 ERROR Error: If ngModel is used within a form tag, either the name attribute must be set or the form control must be defined as 'standalone' in ngModelOptions. confluence kafka ERROR Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer) confluent kafka ERROR Fatal error during KafkaServer startup prepare to shutdown error An unexpected error occurred: "https://registry.yarnpkg.com/@material-ui/icons/-/icons-4.11.2.tgz: ESOCKETTIMEDOUT". ERROR: Could not send notifications com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRequestException: HTTP request error. Status: 403: Forbidden. Error: Error acquiring the state lock ERROR: Could not find a version that satisfies the requirement khabar>=1.1.3 (from cluster ensembles) (from version: 1.0) ERROR: No matching distribution found for hyper>=1.1.3 raise httperror(req.full_url, code, msg, hdrs, fp) urllib.error.httperror: http error 503: service unavailable : new Database Error(message Value, length, name) ^ error: relation "teacher" does not exist Reloading app... events.js:292 throw er; // Unhandled 'error' event ^ Error: EMFILE: too many open files, watch error importTsv SyntaxError: (hbase):4: syntax error, unexpected ',' [Unhandled promise rejection: Error: SERVER_ERROR: [code] 1675030 [message]: Error performing query. [extra]: ] events.js:292 throw er; // Unhandled 'error' event ^ Error: listen EADDRINUSE: address already in use :::3000 Error: Error Updating IAM Role (lambda_exec) Assume Role Policy: MalformedPolicyDocument: Missing required field Principal ERROR Error: Uncaught (in promise): NullInjectorError: StaticInjectorError[t -> t]: StaticInjectorError(Platform: core)[t -> t] Function that replaces character and allow only numbers into the textbox how to run a function firebase update cloud function

Browse Other Code Languages

CodeProZone