Кажется, что ни один из вышеперечисленных решений не работал для меня, если я запустил его на Jupyter Notebook (окно зависает при закрытии, и вам нужно заставить Quit Python закрыть окно).
Я нахожусь на macOS High Sierra 10.13.4, Python 3.6.5, OpenCV 3.4.1.
Ниже приведен код, если вы запустите его как .py-файл (источник: [д0] https://www.learnopencv.com/read-write-and-display-a-video-using-opencv-cpp-python/ [/ д0]). Он открывает камеру, записывает видео, успешно закрывает окно при нажатии «q» и сохраняет видео в формате .avi.
import cv2
import numpy as np
# Create a VideoCapture object
cap = cv2.VideoCapture(0)
# Check if camera opened successfully
if (cap.isOpened() == False):
print("Unable to read camera feed")
# Default resolutions of the frame are obtained.The default resolutions are system dependent.
# We convert the resolutions from float to integer.
frame_width = int(cap.get(3))
frame_height = int(cap.get(4))
# Define the codec and create VideoWriter object.The output is stored in 'outpy.avi' file.
out = cv2.VideoWriter('outpy.avi',cv2.VideoWriter_fourcc('M','J','P','G'), 10, (frame_width,frame_height))
while(True):
ret, frame = cap.read()
if ret == True:
# Write the frame into the file 'output.avi'
out.write(frame)
# Display the resulting frame
cv2.imshow('frame',frame)
# Press Q on keyboard to stop recording
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# Break the loop
else:
break
# When everything done, release the video capture and video write objects
cap.release()
out.release()
# Closes all the frames
cv2.destroyAllWindows()
Это действительно для более старой версии, например. 1.5:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<schemaDirectory>${project.basedir}src/main/resources</schemaDirectory>
<outputDirectory>${project.basedir}src/main/java</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Для версии 2.4, согласно документации, больше нет тега schemaDirectory
https://www.mojohaus.org/jaxb2-maven-plugin/Documentation/v2.4 /xjc-mojo.html
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<outputDirectory>${project.basedir}src/main/java</outputDirectory>
<sources>
<source>${project.basedir}src/main/resources</source>
</sources>
</configuration>
</plugin>